0
업데이트 :if 문에서 BOOL 메서드를 성공적으로 호출하는 방법은 무엇입니까?
: 나는 다른 클래스의 메서드를 호출하고 여기에 내 업데이트 된 코드이다 "는uploadPhoto
방법에 해당하는 경우 그 다음 테스트 목적으로 성공을 표시"말하는 if
문에 넣어 노력하고
- (BOOL)uploadPhoto
{
//upload the image and the title to the web service
[[API sharedInstance] commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:
@"upload",@"command",
UIImageJPEGRepresentation(photo.image,70),@"file",
fldTitle.text, @"title",nil]
onCompletion:^(NSDictionary *json)
{
//completion
if (![json objectForKey:@"error"])
{
//success
[[[UIAlertView alloc]initWithTitle:@"Success!"
message:@"Your photo is uploaded"
delegate:nil cancelButtonTitle:@"Yay!"
otherButtonTitles: nil] show];
}
else
{
//error, check for expired session and if so - authorize the user
NSString* errorMsg = [json objectForKey:@"error"];
[UIAlertView error:errorMsg];
if ([@"Authorization required" compare:errorMsg]==NSOrderedSame)
{
[self performSegueWithIdentifier:@"ShowLogin" sender:nil];
}
}
}];
return YES;
}
:
PhotoScreen *script = [[PhotoScreen alloc] init];
if ([script uploadPhoto])
{
NSLog(@"Sucess!");
}
그것은 더 이상 나에게 오류를 포기하지 않고 때 나는 정상 회담 uploadPhoto 방법에서 사진, 그것은 여기에 "성공"을 기록 does't 그리고 나의 uploadPhoto 방법입니다
내가 뭘 잘못하고 있니?
메소드가'BOOL'을 리턴합니까? 왜 두 번이나 부르니? 또한 if 문에'[script uploadPhoto]'를 넣을 수도 있습니다. – carloabelli
방금 BOOL을 반환하는 메서드를 변경하고 더 이상 오류를주지는 않지만 사진을 업로드하려고하면 "성공"을 표시하지 않습니다. 거기에 할 수있는 방법이 있나요? 일단 메서드가 호출되면 텍스트를 표시합니까? – user3807138
'uploadPhoto' 메쏘드가'YES'를 리턴하면 (BTW -'BOOL' 값들에 대해서'YES' 또는'NO' 만 사용합니다) 단지 "성공"을 기록 할 것입니다. 아마 당신은 당신의 질문에'uploadPhoto' 메서드를 게시해야합니다. – rmaddy