initializing a readonly property. Object c

Posted by tak on Stack Overflow See other posts from Stack Overflow or by tak
Published on 2010-04-29T11:12:26Z Indexed on 2010/04/29 11:17 UTC
Read the original article Hit count: 213

Filed under:

i was trying to create a property which is readonly. i wanted to initialize with a value from the class creating an instance of this class.e.g

@property (readonly) NSString *firstName;

And wanted to initialize it like -(id)initWithName:(NSString *)n{ self.firstName = n; } Once i do this, this compiler shows an error that the readonly property cannot be assigned. So how can i do this?

© Stack Overflow or respective owner

Related posts about iphone