#define STRING_KEY @"string"
#define NUMBER_KEY @"number"
-(NSDictionary *) myMethod
{
....
NSMutableDictionary *toReturn = [NSMutableDictionary dictionary];
[toReturn setObject:myNSString forKey:STRING_KEY];
[toReturn setObject:myNSNumber forKey:NUMBER_KEY];
return toReturn;
}
....
NSDictionary *return = myMethod;
stringReturned = [return objectForKey:STRING_KEY];
nsNumberReturned = [return objectForKey:NUMBER_KEY];
#import "Calc.h"
#define STRING_KEY @"string"
@implementation Calc
-(NSDictionary *) calcDias {
-----------
NSMutableDictionary *toReturn = [NSMutableDictionary dictionary];
[toReturn setObject:final_1 forKey:STRING_KEY];
[toReturn setObject:final_2 forKey:STRING_KEY];
return toReturn;
}
- (IBAction)calc:(id)sender {
calc = [[Calc alloc]init];
NSDictionary *return = calcDias;
final_1 = [return objectForKey:STRING_KEY];
final_2 = [return objectForKey:STRING_KEY];
--------
}
NSDictionary *return = calcDias;
final_1 = [return objectForKey:STRING_KEY];
final_2 = [return objectForKey:STRING_KEY];
I've used the code like this
and get the syntax errors on these 3 linesCode:#import "Calc.h" #define STRING_KEY @"string" @implementation Calc -(NSDictionary *) calcDias { ----------- NSMutableDictionary *toReturn = [NSMutableDictionary dictionary]; [toReturn setObject:final_1 forKey:STRING_KEY]; [toReturn setObject:final_2 forKey:STRING_KEY]; return toReturn; } - (IBAction)calc:(id)sender { calc = [[Calc alloc]init]; NSDictionary *return = calcDias; final_1 = [return objectForKey:STRING_KEY]; final_2 = [return objectForKey:STRING_KEY]; -------- }
I' ve defined "final_1" and "final_2" as NSString.Code:NSDictionary *return = calcDias; final_1 = [return objectForKey:STRING_KEY]; final_2 = [return objectForKey:STRING_KEY];
Can you help ?
I've used the code like this
Code:#import "Calc.h" #define STRING_KEY @"string" @implementation Calc -(NSDictionary *) calcDias { ----------- NSMutableDictionary *toReturn = [NSMutableDictionary dictionary]; [toReturn setObject:final_1 forKey:STRING_KEY]; [toReturn setObject:final_2 forKey:STRING_KEY]; return toReturn; } - (IBAction)calc:(id)sender { calc = [[Calc alloc]init]; NSDictionary *return = calcDias; final_1 = [return objectForKey:STRING_KEY]; final_2 = [return objectForKey:STRING_KEY]; -------- }
and get the syntax errors on these 3 lines
Code:NSDictionary *return = calcDias; final_1 = [return objectForKey:STRING_KEY]; final_2 = [return objectForKey:STRING_KEY];
I' ve defined "final_1" and "final_2" as NSString.
Can you help ?