Questions tagged [nonatomic]

15 questions
1942
votes
28 answers

What's the difference between the atomic and nonatomic attributes?

What do atomic and nonatomic mean in property declarations? @property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *userName; What is the operational difference between…
Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
11
votes
5 answers

Will atomic operations block other threads?

I am trying to make "atomic vs non atomic" concept settled in my mind. My first problem is I could not find "real-life analogy" on that. Like customer/restaurant relationship over atomic operations or something similar. Also I would like to learn…
Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158
9
votes
3 answers

Objective-c properties for primitive types

In Objective-C Does it ever make sense to specify a property for a primitive type as nonatomic? I'm wondering about the difference between these two properties: @property (nonatomic) BOOL myBool; @property BOOL myBool;
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
8
votes
1 answer

Atomic access to non-atomic memory location in C++11 and OpenMP?

OpenMP, in contrast to C++11, works with atomicity from a perspective of memory operations, not variables. That allows, e.g., to use atomic reads/writes for integers being stored in a vector with unknown size at compile time: std::vector v; //…
Daniel Langr
  • 22,196
  • 3
  • 50
  • 93
7
votes
3 answers

Objective-C: Defaults to atomic for scalar properties?

A friend told me that the @property default for scalar properties (BOOL, NSInteger, etc.) is nonatomic. I.e., @property BOOL followVenmo; defaults to @property (nonatomic) BOOL followVenmo; But, I was always under the impression that the default…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
5
votes
1 answer

Difference between private instance variable and property in class extension (Objective-c 2.0)

What are the differences (if any) between the following Objective-c 2.0 code snippets: // in MyClass.h @interface MyClass @private NSString *myString; @end and // in MyClass.m @interface MyClass () @property (nonatomic, copy) NSString…
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
5
votes
1 answer

How to remove function from list in R?

I have list with two functions: foo <- function() { print('foo') } bar <- function() {} l <- list(foo, bar) How can I remove function foo without knowing its index? I've tried this (to get indexes for sub setting): > which(l == foo) Error in l ==…
jcubic
  • 61,973
  • 54
  • 229
  • 402
4
votes
1 answer

Why atomic and nonatomic concept has removed from swift

There is no nonatomic keyword in swift, Why nonatomic not required in swift as it exist in objective c.
Mahendra Y
  • 1,941
  • 20
  • 26
3
votes
5 answers

Dangers of simultaneous write and read of a boolean in a simple situation

I've read some similar questions but the situations described there are bit more complicated. I have a bool b initialized as false in the heap and two threads. I do understand that operations with bools are not atomic, but please read the…
Shamdor
  • 3,019
  • 5
  • 22
  • 25
2
votes
2 answers

What is the difference between a strong and weak button in Objective c?

When declaring a button, there are always two options as properties for the button:strong and weak. What is the difference between them? Also, what it nonatomic? For example: @property (weak, nonatomic) IBOutlet UIButton *MyButton;
Neil Shweky
  • 893
  • 2
  • 10
  • 23
0
votes
0 answers

C - volatile qualifier while lock is held

Do I need the volatile qualifier for variables only accessed while a lock is held? In this code, could removing the volatile qualifier from n possibly change the behavior when concurrent_foo is executed concurrently. #ifndef __GNUC__ #error…
Isabell Cowan
  • 113
  • 2
  • 9
0
votes
0 answers

What is the value of property in ios

In Atomic we all know one thread is access one object at a time. if we have 3 thread want to access one object then first come first serve method apply to thread ... but in non atomic all thread is simultaneously access the oject and produce the…
0
votes
2 answers

Deallocating nonatomic copy setter

I am trying to create non-atomic copy accessors, and I read everywhere that the object should be released at the end. So, if you could help me understand whether I am doing it properly, I would appreciate it. Will the following be…
Igor Tupitsyn
  • 1,193
  • 3
  • 18
  • 45
0
votes
1 answer

are nonatomic and atomic thread unsafe in objective c?

I read that nonatomic and atomic both are thread unsafe. but nonatomic is faster because it allows faster access means asynchronously and atomic is slower it allows slower access synchronously.
Nitesh
  • 1,924
  • 21
  • 31
0
votes
1 answer

Do I have to use nonatomic property in objective-c ios programing?

I'm developing an iPhone app. All the iPhone development books I have read use nonatomic property. And IBOutlets which xcode generates also use nonatomic keyword. But I don't like to write nonatomic on every property because it decrease readability…
js_
  • 4,671
  • 6
  • 44
  • 61