I have a function that gives 2 different String values that are returned :
-(NSString*)load:(NSDictionary *)dict
{
NSDictionary *dataDict = [self objectForId:@"data" fromDict:dict withDefault:nil];
if (dataDict) {
NSDictionary *success = [self objectForId:@"success" fromDict:dataDict withDefault:nil];
NSString *str = [NSString stringWithFormat:@"%@", success];
if ([str isEqualToString: @"1"])
{
NSDictionary *idDict = [self objectForId:@"id" fromDict:dataDict withDefault:nil];
if (idDict) {
NSString *idString = [NSString stringWithFormat:@"%@", idDict];
return idString;
}
} else {
NSDictionary *messages = [self objectForId:@"messages" fromDict:dataDict withDefault:nil];
if (messages) {
NSDictionary *messageDict = (NSDictionary *)messages;
NSArray *type = messageDict[@"type"];
if (type.count > 0) {
NSString *messageString = type[0][@"message"];
return messageString;
}
}
}
}
return nil;
}
And accessing the stringValue like this :
NSString *string = [className load:dict];
Now I want to write if else statements for "idString" and "messageString" return values. How do I differentiate the 2 return values?
Aucun commentaire:
Enregistrer un commentaire