Я новичок в Objective C и у меня есть некоторые проблемы ....
Это мой код:
1)
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»