Re: Accessing array in thread safe way

2012-03-07 Thread Mike Abdullah
Have you read https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html ? On 6 Mar 2012, at 19:51, Jan E. Schotsman wrote: Hello, I have an array of progress values (number objects) for subprojects, from which I

Re: Accessing array in thread safe way

2012-03-07 Thread Conrad Shultz
On 3/6/12 11:51 AM, Jan E. Schotsman wrote: Hello, I have an array of progress values (number objects) for subprojects, from which I calculate the overall progress . The array is an atomic property of the project class. Is it safe to access this array from multiple threads, using methods

Re: Accessing array in thread safe way

2012-03-07 Thread Sean McBride
On Tue, 6 Mar 2012 20:51:10 +0100, Jan E. Schotsman said: I have an array of progress values (number objects) for subprojects, from which I calculate the overall progress . The array is an atomic property of the project class. Is it safe to access this array from multiple threads, using

Re: JSON validator for Xcode

2012-03-07 Thread Marco Tabini
BOOL isTurnableToJSON = [NSJSONSerialization isValidJSONObject: responseData]; NSLog(@Is legit for JSON: %d, isTurnableToJSON ); NSLog(@Is legit for JSON: %@, isTurnableToJSON ? @YES : @NO); // this is how we handle a bool :/ Are you sure that you are using isTurnableToJSON the

Re: Accessing array in thread safe way

2012-03-07 Thread Fritz Anderson
On 6 Mar 2012, at 1:51 PM, Jan E. Schotsman wrote: Is it safe to access this array from multiple threads, using methods like objectAtIndex and replaceObjectAtIndex? You can access immutable Foundation objects across threads, but not mutable ones, which is what you're thinking of. Your

Re: Accessing array in thread safe way

2012-03-07 Thread Wim Lewis
On 6 Mar 2012, at 11:51 AM, Jan E. Schotsman wrote: I have an array of progress values (number objects) for subprojects, from which I calculate the overall progress . The array is an atomic property of the project class. Is it safe to access this array from multiple threads, using methods

Re: Accessing array in thread safe way

2012-03-07 Thread Nick Zitzmann
On Mar 6, 2012, at 12:51 PM, Jan E. Schotsman wrote: Hello, I have an array of progress values (number objects) for subprojects, from which I calculate the overall progress . The array is an atomic property of the project class. Is it safe to access this array from multiple threads,

Re: Accessing array in thread safe way

2012-03-07 Thread Jonathan Hull
I believe that reading is thread safe, but writing is not. You could wrap all access to the array in methods which use the same GCD queue to read/write, and that would be thread safe. Thanks, Jon On Mar 6, 2012, at 11:51 AM, Jan E. Schotsman wrote: Hello, I have an array of progress

Re: Accessing array in thread safe way

2012-03-07 Thread Jens Alfke
On Mar 6, 2012, at 11:51 AM, Jan E. Schotsman wrote: Is it safe to access this array from multiple threads, using methods like objectAtIndex and replaceObjectAtIndex? It depends. The short answer: you should use your own synchronization around your own critical sections instead of relying

Re: JSON validator for Xcode

2012-03-07 Thread Jens Alfke
On Mar 6, 2012, at 11:59 AM, Alex Zavatone wrote: BOOL isTurnableToJSON = [NSJSONSerialization isValidJSONObject: responseData]; You’re calling it on the NSData? That’s the wrong way round. You call that method to ask if you can turn an in-memory data structure _into_ JSON data, not to see

No indentation when displaying an icon in an NSMenuItem

2012-03-07 Thread Prime Coderama
I am trying to add an icon to only one NSMenuItem item but it is indenting the icon and text by 1 level. I tried to set the setIndentationLevel to 0 but that doesn't work. An example of what I am trying to achieve can be seen in the Wireless status bar menu where the tickbox is displayed

Re: Releasing WSMethodInvocationInvoke()

2012-03-07 Thread Sean McBride
On Mon, 5 Mar 2012 13:44:24 -0800, Gus Mueller said: That's because it's missing a CF_RETURNS_RETAINED in the header for that method, which the analyzer needs to know what's going on. I'm not sure there's any way around this other than filing a bug and hoping Apple updates the headers in the

NSTableCellView subclass layout from independent nib

2012-03-07 Thread Seth Willits
I have more than one table which will share a certain type of table cell. In cell-based table cells, I'd make an NSCell subclass, add whatever needed properties there are, and do all the drawing there. The layout of the cell is part of the subclass itself. In view-based tables, I'd create a

Re: Accessing array in thread safe way

2012-03-07 Thread Roland King
No. The atomic just means you can access the array property atomically, not that methods called on that array are synchronized. For that you need to do your own synchronization, like using @synchronized on the array itself. On 7 Mar, 2012, at 3:51, Jan E. Schotsman jesc...@xs4all.nl wrote:

Re: Finding object array index when iterating through array

2012-03-07 Thread Marco Tabini
I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index position or do I have to add a counter? [array indexOfObject:object] should do the trick, though, if

Re: Accessing array in thread safe way

2012-03-07 Thread Charles Srstka
On Mar 6, 2012, at 1:51 PM, Jan E. Schotsman wrote: I have an array of progress values (number objects) for subprojects, from which I calculate the overall progress . The array is an atomic property of the project class. Is it safe to access this array from multiple threads, using methods

Re: Finding object array index when iterating through array

2012-03-07 Thread Roland King
You have to add a counter. On 7 Mar, 2012, at 4:42, Prime Coderama prime.coder...@gmail.com wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index

Re: Finding object array index when iterating through array

2012-03-07 Thread Seth Willits
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index position or do I have to add a counter? 1) Add

Re: Finding object array index when iterating through array

2012-03-07 Thread Conrad Shultz
On 3/6/12 12:42 PM, Prime Coderama wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index position or do I have to add a counter? You could use

Re: Finding object array index when iterating through array

2012-03-07 Thread Jens Alfke
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: Is there way to obtain the object's current array index position or do I have to add a counter? You can add a counter, which is pretty easy. Or you can call -enumerateObjectsAtIndexes:options:usingBlock:, which passes the index as well as

Re: Finding object array index when iterating through array

2012-03-07 Thread Kyle Sluder
On Mar 6, 2012, at 12:42 PM, Prime Coderama wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index position or do I have to add a counter? This is

Re: Finding object array index when iterating through array

2012-03-07 Thread Keary Suska
On Mar 6, 2012, at 1:42 PM, Prime Coderama wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index position or do I have to add a counter? You have

Re: Accessing array in thread safe way

2012-03-07 Thread Joar Wingfors
No. Please see: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html Joar On 6 mar 2012, at 11:51, Jan E. Schotsman wrote: Hello, I have an array of progress values (number objects) for subprojects,

Re: Finding object array index when iterating through array

2012-03-07 Thread Joar Wingfors
If you use a block-iterator, the index is passed as a parameter to the iterator block. Joar On 6 mar 2012, at 12:42, Prime Coderama wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to

Re: Finding object array index when iterating through array

2012-03-07 Thread Graham Cox
On 07/03/2012, at 7:42 AM, Prime Coderama wrote: I have an array and I am iterating through it using this technique: for (id object in array) { // do something with object } Is there way to obtain the object's current array index position or do I have to add a counter? [array

Re: UIKit-additions and class references

2012-03-07 Thread Richard Somers
On Mar 6, 2012, at 2:28 PM, Mikkel Islay wrote: Does anyone know the reason why the UIKit-additions for NSString, NSValue etc. aren't mentioned in the respective class references in the Apple documentation for iOS? It appears that the same NSString Class Reference documentation for the Mac