Is there any way to call or pass a method on a property. I understand how to set and get properties but how do I manipulate them? I'm trying to remove punctuation on string using object oriented programing. The act of removing punctuation from an input string is written as a method.
main.m
TDItem *newItem = [[TDItem alloc] init];
[newItem setItemString:@"Get the mail next Tuesday!"];
NSLog(@"\nCreated Item: %@", [newItem itemString]);
NSString *itemStringWithoutPunctuation = [[NSString alloc] init];
[newItem itemStringWithoutPunctuation:[newItem itemString]];
[newItem setItemString:itemStringWithoutPunctuation];
NSLog(@"\nCreated Item: %@", [newItem itemString]);
TDItem.h
@interface TDItem : NSObject
@property NSString *itemString;
// Formating methods
- (NSString *)itemStringWithoutPunctuation:(NSString *)itemString;
TDItem.m
- (NSString *)itemStringWithoutPunctuation:(NSString *)itemString
{
NSString* itemStringWithoutPunctuation = [[itemString componentsSeparatedByCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] componentsJoinedByString:@" "];
return itemStringWithoutPunctuation;
}
The debug console prints out a blank for the new itemString value.
Debuger
Created Item: Get the mail next Tuesday!
Created Item:
If this the completely wrong what to go about changing a property value?