I have some text fields. Eg this one
TTMessageField *field = [fields objectAtIndex:0];
NSLog(@"%S", field.description);
NSLog(@"%@", field);
TTMessageField Class Reference.
The second line prints
To: (
"recipient"
)
and the third
To: (\n recipient\n)
I am not sure why but the description does not return the recipient only. It is wrapped by this To:() like you see above.
- (NSString*)description {
return [NSString stringWithFormat:@"%@", _title];
}
Is it possible to extract just the recipient? Something like
NSString *str = field.description;
and then use a regex to get the recipient?
Have you tried using other method name than "description"? In fact -description method is NSObject's method and causes any object to print its values. There might be some kind of overriding interference there, give a try to some other name, "-descriptionString" for instance.
I'll assume that you're using Three20 for this. Try this
TTMessageField *field = [fields objectAtIndex:0];
NSString *myString = [field title];
I could change TTMessageField
to TTMessageRecipientField
which extends TTMessageField. TTMessageRecipientField has a field recipients which is an NSArray and holds the names of the recipients:
TTMessageRecipientField *field = [fields objectAtIndex:0];
NSArray *recipient = [field recipients];
NSString *str = [recipient objectAtIndex:0];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.