@property requires a method or methods to be accessible. The easy way to do this is with
@synthesize, but otherwise you can easily code the method yourself. For example, you could consider
length to be a property of NSString, even though it is not clear whether the value is stored or calculated. In fact, the following code works as one might expect:
Code:
NSMutableString *aString = [NSMutableString alloc];
aString = aString.init;
[aString setString:@"words"];
NSInteger itsLen = aString.length;
Though, that one would use dot syntax with
- init is highly dubious, it just points out that a method with no parameters that returns a value can use dot syntax. (I tried to write
aString.string = @"words"; but my compiler would not accept that.)