MaxLXJ MaxLXJ - 3 years ago 92
iOS Question

objective-c property name: use uppercase character as first character of property name

It seems that the property name in objective-c must start with lowecase letters, since the setter is writen in camel case.

Is there any method to define a property(which has a setter method) start with upper case charaters?

Avi Avi
Answer Source
@import Foundation;

@interface M : NSObject

@property (nonatomic, strong) NSString *Uppercase;


@implementation M


int main(int argc, char **argv)
    M *m = [M new];
    m.Uppercase = @"I hate conventions.";

    NSLog(@"%@", m.Uppercase);

    return 0;

The above gives the following output:

➜  test  ./a.out 
2016-10-23 09:58:21.291 a.out[52998:1646241] I hate conventions.

As you can see from the code, both the setter and getter are used the same way as any other property.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download