-2

In general, I do my interfaces like this:

@interface Gui2UtilityCell : NSObject{
    NSString* myString;
}
@property(nonatomic,strong) NSString* mystring;

@end

In this case, the NSString* myString; is it Mandatory ? If yes, what the difference between the previous code and this one:

@interface Gui2UtilityCell : NSObject

@property(nonatomic,strong) NSString* mystring;

@end
Eimantas
  • 48,927
  • 17
  • 132
  • 168
Anthony
  • 2,801
  • 3
  • 30
  • 49
  • 5
    This has been asked so many times. Please check before asking. – iNoob Feb 15 '12 at 09:20
  • 1
    Guys do not downvote such questions because: 1. It is simplier to ask then to find. 2. It allows noobs like me to answer and raise reputation. Though, Anthony you should of course use a search. – Stas Feb 15 '12 at 11:13
  • possible duplicate of [Do I still need to declare the instance variable if I am using @property?](http://stackoverflow.com/questions/8459987/do-i-still-need-to-declare-the-instance-variable-if-i-am-using-property) – jscs Feb 15 '12 at 18:42
  • 1
    also http://stackoverflow.com/questions/4903651/is-there-any-reason-to-declare-ivars-if-youre-using-properties-exclusively-in-o http://stackoverflow.com/questions/2159725/difference-between-interface-declaration-and-property-declaration http://stackoverflow.com/questions/5572114/why-declare-object-in-interface-when-used-property-in-xcode-4 – jscs Feb 15 '12 at 18:47

2 Answers2

1

If you don't create a variable by yourself it will be created automatically. You may create the variable for your property with the name: yourPropertyName_ (in your case it will be myString_) to differentiate the instance variable and the name of property.

Stas
  • 9,925
  • 9
  • 42
  • 77
0

As I understand it, there is no difference.

There is a good answer here: Do declared properties require a corresponding instance variable?

Community
  • 1
  • 1
Warren
  • 61
  • 2