Reputation: 7484
this gives me an error, "Bad Reciever type 'NSIntegar" (aka 'int').
NSString *tempTag = [((UITextField *)[self.dataSetDictionary objectForKey:key]).tag stringValue];
trying to typecast a uitextfield's tag to an string. i can use [NSString stringWithFormat] fine, just can't figure out why this way won't work.
Upvotes: 0
Views: 642
Reputation: 2830
tag
is a property of UIView object of NSInteger data type. You cannot pass messages to it. stringValue
should be called on NSNumber
. What you should be doing is
NSString *tempTag=(NSString*)[[NSNumber numberWithInt:[(UITextField*)[self.dataSetDictionary objectForKey:key] tag]] stringValue];
Upvotes: 2
Reputation: 135578
You have to use stringWithFormat:
UITextField *textField = (UITextField *)[self.dataSetDictionary objectForKey:key];
NSString *tempTag = [NSString stringWithFormat:@"%d", textField.tag];
just can't figure out why this way won't work.
Because tag
is a scalar integer and not an object. You can't send messages like stringValue
to non-objects.
Upvotes: 4