내 코드에서 일부입니다 :이상한 "좀비"+ getArgument : atIndex 방법은 여기
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = [[UIScreen mainScreen] bounds];
_webView = [[UIWebView alloc] initWithFrame:frame];
[_webView setHidden:NO];
[self.view addSubview:_webView];
_vk = [[DPVkontakteCommunicator alloc] initWithWebView:_webView];
DPVkontakteUserAccount *user;
NSString *accessToken = [[NSUserDefaults standardUserDefaults]
objectForKey:@"accessToken"];
NSInteger userId = [[[NSUserDefaults standardUserDefaults]
objectForKey:@"userId"] integerValue];
user = [[DPVkontakteUserAccount alloc]
initUserAccountWithAccessToken:accessToken
userId:userId];
NSLog(@"%@", user);
[user setSuccessBlock:^(NSDictionary *dictionary)
{
NSLog(@"%@", dictionary);
}];
NSDictionary *options = @{@"uid":@"1"};
// [user usersGetWithCustomOptions:@{@"uid":@"1"}]; // Zombie
[user usersGetWithCustomOptions:options]; // Not zombie
// __block NSDictionary *options = @{};
//
// [_vk startOnCancelBlock:^{
// NSLog(@"Cancel");
// } onErrorBlock:^(NSError *error) {
// NSLog(@"Error: %@", error);
// } onSuccessBlock:^(DPVkontakteUserAccount *account) {
// NSLog(@"account:%@", account);
//
// [account setSuccessBlock:^(NSDictionary *dictionary)
// {
// NSLog(@"%@", dictionary);
// }];
//
// [account docsGetUploadServerWithCustomOptions:options];
// }];
}
여기에 userGetWithCustomOptions를 처리하는 부분은 다음과 같습니다 방법 :
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
NSString *methodName = NSStringFromSelector([anInvocation selector]);
NSDictionary *options;
[anInvocation getArgument:&options
atIndex:2];
NSArray *parts = [self parseMethodName:methodName];
NSString *vkURLMethodSignature = [NSString stringWithFormat:@"%@%@.%@",
kVKONTAKTE_API_URL,
parts[0],
parts[1]];
// appending params to URL
NSMutableString *fullRequestURL = [vkURLMethodSignature mutableCopy];
[fullRequestURL appendString:@"?"];
[options enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop)
{
[fullRequestURL appendFormat:@"%@=%@&", key, [obj encodeURL]];
}];
[fullRequestURL appendFormat:@"access_token=%@", _accessToken];
// performing HTTP GET request to vkURLMethodSignature URL
NSURL *url = [NSURL URLWithString:fullRequestURL];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation;
operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:urlRequest
success:^(NSURLRequest *request,
NSHTTPURLResponse *response,
id JSON)
{
_successBlock(JSON);
}
failure:^(NSURLRequest *request,
NSHTTPURLResponse *response,
NSError *error,
id JSON)
{
_errorBlock(error);
}];
[operation start];
}
문제가 내가 "옵션"변수를 사용할 때 제대로 작동하지만 직접 값을 사용할 때 응용 프로그램이 실패합니다. 프로파일 사용하기 나는 메소드 호출이 할당 해제 된 객체를 지시한다는 것을 알았다.
왜 이런 일이 발생합니까? 도움이되는 다른 코드가 없습니다.
ViewController.m 코드 : https://gist.github.com/AndrewShmig/5398546
DPVkontakteUserAccount.m : https://gist.github.com/AndrewShmig/5398557
당신이 적어도 추가 할 수 있습니다 대신에, 또는 그것으로 "포인터가 무효로하려면"다음 나중에 강한 참조로 변환는 "unsafe_unretained하는 포인터를"통과 'DPVkontakeUserAccount'의'forwardInvocation :'메소드의 나머지 부분을 읽고, 특히'options' 변수를 참조하여'usersGetWithCustomOptions :'를 호출 한 다음에 나오는 첫 번째 코드 샘플을 컨텍스트에 넣으십시오. 아마 민중이 너를 도우려고 도와 줄거야. – CRD
@CRD 지금은 괜찮습니까? – AndrewShmig
여러분을 도울 것입니다. 당신은 "프로필을 사용하여 그 메소드 호출이 할당 해제 된 객체를 지시한다는 것을 알았습니다."라고 말하면 어떤 메소드가 호출됩니까? 'enumerateKeysAndObjectsUsingBlock :'가능성이 있습니까? – CRD