Updated:
I am trying to call a method from a different class and put it in an if
statement saying "if the uploadPhoto
method is true then display success for testing purposes" here is my updated code:
PhotoScreen *script = [[PhotoScreen alloc] init];
if ([script uploadPhoto])
{
NSLog(@"Sucess!");
}
It isn't giving me the error anymore but when I summit the photo from the uploadPhoto method, it does't log the "Success" And here is my uploadPhoto method:
- (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;
}
What am I doing wrong?