I want to call a method which returns two values
basically lets say my method is like the below (want to return 2 values)
NSString* myfunc
{
NSString
I see everyone has mentioned an NSArray but I'd go with an NSDictionary so the values don't have to be added in order or even at all. This means it is able to handle a situation where you only want to return the second string.
- (NSDictionary*)myFunction {
NSString *myString1 = @"string1";
NSString *myString2 = @"string2";
return [NSDictionary dictionaryWithObjectsAndKeys: myString1, @"key1", myString2, @"key2", nil];
}
NSDictionary *myDictionary = [self myFunction]
NSString *string1 = [myDictionary objectForKey:@"key1"];
NSString *string2 = [myDictionary objectForKey:@"key2"];