LoginSignup
3
3

More than 5 years have passed since last update.

Xcode5.0+ARC環境で非NSObject型のプロパティのsetアクセサのセマンティクス指定子を省略した場合のデフォルト値

Posted at

Xcode5.0+ARC環境でプロパティのsetアクセサのセマンティクス指定子を省略した場合のデフォルト値はstrongのようですが、int等の非NSObject型の場合もstrongというのはおかしかということで調べてみました。

Hoe.h
@interface Hoe : NSObject

@property (nonatmic) int intValue;

+ (void)showPropertyAttribute;

@end
Hoe.m
#import "objc/runtime.h"

@implementation Hoe

+ (void)showPropertyAttribute {
    unsigned int outCount;
    objc_property_t *properties = class_copyPropertyList([self class], &outCount);

    for (int i = 0; i < outCount; i++) {
        objc_property_t property = properties[i];
        fprintf(stdout, "%s\n", property_getAttributes(property));
    }
}

@end

結果

Ti,N,V_intValue

というわけで、非NSObject型の場合はデフォルトはstrongではなくassignであることが分かりました。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3