Reputation: 141
I'm new to obj-c and I'm trying to code a simple "inputs to plist" app. I have two inputs:
@property (strong, nonatomic) IBOutlet UITextField *costo;
@property (strong, nonatomic) IBOutlet UITextField *descrizione;
and I synthesize them in the .m file
@synthesize costo;
@synthesize descrizione;
then I have a function saveData() with:
NSNumber *newValue = [NSNumber numberWithInt:[costo.text intValue]];
[mutableDictCopy setObject:newValue forKey:[descrizione.text]];
this function works fine with costo.text, but then I get an "Expected identifier" error with descrizione.text. if I switch it with @"foo", all goes fine and it updates my plist. Where do I get wrong?
Upvotes: 1
Views: 179
Reputation: 556
Use This
[mutableDictCopy setObject:newValue forKey:descrizione.text];
instead of
[mutableDictCopy setObject:newValue forKey:[descrizione.text]];
Upvotes: 3
Reputation: 13547
You are mixing the member and message syntaxes. This is OK:
[descrizione text]
The following is also OK. It means the same thing.
descrizione.text
This is not OK:
[descrizione.text]
Upvotes: 1