0

If i have the following in my .h file:

@property UIButton *connect;

Is this the same as:

@property(atomic, strong) UIButton *connect;

Eg what are the default 'arguments' in an @property declaration?

Chris
  • 39,719
  • 45
  • 189
  • 235
  • You can also have a look here : http://stackoverflow.com/questions/15362157/why-are-cocoas-iboutlet-properties-atomic-by-default-and-cocoa-touchs-arent/15362414#15362414 – Anoop Vaidya Mar 20 '13 at 04:21

4 Answers4

2

According to the docs, properties default to atomic and strong.

Properties are Atomic by Default

Use Strong and Weak Declarations to Manage Ownership - see the next sentence.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Thanks a lot. I'm teaching iOS development at the moment, and figured that it'd be easier to just teach the @property method without the 'arguments' - just wanted to make sure they were sensible defaults. – Chris Mar 20 '13 at 04:04
  • @Downvoter - why the down vote? The question is answered correctly with links to the documentation. – rmaddy Mar 20 '13 at 04:08
  • 2
    Yes , at least leave some comment before downvoting. Otherwise that is something like negative mentality. – V-Xtreme Mar 20 '13 at 04:14
  • @rmaddy: I dint downvote. But still I am confused...http://stackoverflow.com/questions/15362157/why-are-cocoas-iboutlet-properties-atomic-by-default-and-cocoa-touchs-arent/15362414#15362414 – Anoop Vaidya Mar 20 '13 at 04:22
  • @AnoopVaidya The docs state that properties are atomic by default. What's the confusion? – rmaddy Mar 20 '13 at 04:25
  • but for outlets it is non-atomic and weak, and even outlets are properties. And I have checked in XC4.3- it was atomic, in XC4.4+ it is non-atomic. Am I wrong? – Anoop Vaidya Mar 20 '13 at 04:27
  • @AnoopVaidya Is this documented anywhere? I don't use IB so I have no idea of outlets are treated differently. – rmaddy Mar 20 '13 at 04:29
  • Dont know about doucumentation but when I use storyboard, and drag from a UIButton to .h it creates as non-atomic. – Anoop Vaidya Mar 20 '13 at 04:33
  • @AnoopVaidya But that's an explicit declaration, right? In other words, is `non-atomic` explicitly added to the `@property`? If so then that has nothing to do with this question. – rmaddy Mar 20 '13 at 04:34
  • I dont have much idea about this. And i think someone downvoted on this ground only. – Anoop Vaidya Mar 20 '13 at 04:40
  • Hey @rmaddy, thanks a lot for the links, totally appreciated. Ignore the haters that have taken over this site :) – Chris Mar 21 '13 at 01:20
2

strong and atomic is the default option in the property declaration see this link:link

V-Xtreme
  • 7,230
  • 9
  • 39
  • 79
1

Yes. atomic and strong are default attributes. It seems to be spread out in the docs though it took a longer than I thought to find:

http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html

Mike D
  • 4,938
  • 6
  • 43
  • 99
1

by default properties are atomic as documented here and are strong as mentioned here (see just above the 'avoid strong reference cycles')

abbood
  • 23,101
  • 16
  • 132
  • 246