我的目標C新和我有一些問題.... 這是我的代碼: 1)EXC_BAD_ACCESS NSString的目標C
testAppDelegate.h (not all):
@interface testAppDelegate : NSObject <NSApplicationDelegate> {
IBOutlet NSWindow *windowLogin;
IBOutlet NSWindow *windowContactList;
IBOutlet NSTextField *memStatus;
NSString *access_token, *expires_in, *user_id;
NSMutableArray *records;}
2)testAppDelegate.m(不是全部):
int posInStr(NSString *subString, NSString *genString){
NSRange match;
match = [genString rangeOfString:subString];
return match.location;
}
NSString* pars(NSString *str_,NSString *str,NSString *_str){
NSString *tmp;
int startPos = posInStr(str_,str) + [str_ length];
tmp = [str substringFromIndex:startPos];
int finishPos = posInStr(_str, tmp);
return [tmp substringToIndex:finishPos];
}
-(IBAction)but2Click: (id)sender{
NSString *tmp2 = access_token;
NSString *tmp = [NSString stringWithFormat:@"https://api.vkontakte.ru/method/messages.getDialogs?count=3&access_token=%@",tmp2];
NSURL *url = [NSURL URLWithString:tmp];
NSLog(@"%@",tmp);
NSLog(@"%@",url);
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:@selector(showLoaded)];
[request startAsynchronous];
}
-(IBAction)but1Click:(id) sender{
NSURL *url = [NSURL URLWithString:@"http://api.vkontakte.ru/oauth/authorize?client_id=293&scope=friends,messages&redirect_uri=http://api.vkontakte.ru/blank.html&display=popup&response_type=token"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestFinishedtest:)];
[request startAsynchronous];
}
- (void)requestFinishedtest:(ASIHTTPRequest *)request
{
[memStatus setStringValue:@"Loading..."];
NSString *tmp = [NSString stringWithFormat:@"%@",[request url]];
[tmp retain];
access_token = pars(@"access_token=", tmp, @"&");
NSLog(@"%@",access_token);
expires_in = pars(@"expires_in=", tmp ,@"&");
user_id = pars(@"user_id=", [NSString stringWithFormat:@"%@&",tmp], @"&");
[memStatus setStringValue:@"Logined"];
[windowLogin orderOut:nil];
[windowContactList makeKeyAndOrderFront:self];
[NSApp activateIgnoringOtherApps:YES];
}
我的問題: 「EXC_BAD_ACCESS」 在 「but2Click」
在哪一行該功能是錯誤其他提示? – Maz 2011-05-28 18:04:07