1

If I create property, for example:

@property NSString *selectedSubProductId;

and create setter and getter:

- (NSString *)selectedSubProductId {}

- (void)setSelectedSubProductId:(NSString *)value_ {}

XCode says that "Deault property attribute 'assign' not appropriate for non-gc object". Do attributes have any meaning in this case? Does it matter if i make them copy or assign or are they only cue for @synthesize to create desired methods? If so, how should I disable the warnings?

janusfidel
  • 7,682
  • 4
  • 27
  • 50
Rafał
  • 1,068
  • 1
  • 8
  • 21

2 Answers2

1

If it is object, you should use retain/copy property modifier.

For example:

@property (nonatomic, retain) NSString *selectedSubProductId;

If the modifiers are missing, assign modifier is enabled by default. But it is only valid for scalar (int, float...) or struct.

You may get more details in Apple Documentation

HKTonyLee
  • 2,087
  • 19
  • 25
0

That warning says that you are using a default property atribute (assign) because you forgot to say how do you want to hold your object.

If you want to "remove" the warning use a retain/copy property: @property (copy) NSString *selectedSubProductId;

However, in Strings you should use copy. For more information please visit this question on stackoverflow.

Community
  • 1
  • 1
Tiago Almeida
  • 13,437
  • 3
  • 62
  • 80