Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Etan Kissling
Got a strange issue here. I have a small model class that stores a NSNumber. @objc(Foo) final class Foo : NSObject { dynamic var x = 0 override init() { self.x = Int(arc4random()) } init(x: Int) { self.x = x } } In my ViewController, there is a NSSet-ba

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Quincey Morris
On Jan 8, 2016, at 07:14 , Etan Kissling wrote: > > In my ViewController, there is a NSSet-based collection of such objects. > > final class ViewController: NSViewController { >dynamic var foos: Set = [Foo(x: 0), Foo(x: 1), Foo(x: 2)] > } I don’t think it’s true that ‘foos’ is a NSSet. Rath

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Etan Kissling
As the comments in the sample project describe in the introductory comments, modifying the code to force an NSSet does not solve the problem. > On 08 Jan 2016, at 18:39, Quincey Morris > wrote: > > On Jan 8, 2016, at 07:14 , Etan Kissling > wrote: >> >> In my View

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Etan Kissling
In fact, it makes things even worse, and freezes up Xcode when expanding the set in the debugger. > On 08 Jan 2016, at 18:59, Etan Kissling wrote: > > As the comments in the sample project describe in the introductory comments, > modifying the code to force an NSSet does not solve the problem.

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Etan Kissling
dynamic var foos: NSMutableSet = [Foo(x: 0), Foo(x: 1), Foo(x: 2)] (lldb) e/x foos as! Set Comparing 2 to 0 Comparing 1 to 0 (Set) $R0 = ([0] = , [1] = , [2] = ) On 08 Jan 2016, at 19:00, Etan Kissling mailto:kissl...@oberon.ch>> wrote: In fact, it makes things even worse, and freezes up

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Quincey Morris
On Jan 8, 2016, at 09:59 , Etan Kissling wrote: > > As the comments in the sample project describe in the introductory comments, > modifying the code to force an NSSet does not solve the problem. a. I believe your debugger display problems are just that — problems in the debugger, not necessari

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Etan Kissling
Wow, thanks for the various hints. a. Could be :-) However, since the Find feature of the minimal app stops working properly after modifying the collection, there's definitely something fishy. b. Yep, the dynamic keyword can afaik only be applied to types that are representable in objc. c. Hm

Obtaining a value from a hex representation

2016-01-08 Thread Carl Hoefs
A user enters the hexadecimal representation of a number like "0x31C8FD" into a text field. The intValue of such strings is 0. Is there a Cocoa method (like .hexValue) to convert the hex representation string into a value? -Carl ___ Cocoa-dev mailin

Re: Modifying Set via NSArrayController breaks Set in weird way

2016-01-08 Thread Quincey Morris
On Jan 8, 2016, at 13:44 , Etan Kissling wrote: > > a. Could be :-) However, since the Find feature of the minimal app stops > working properly after modifying the collection, there's definitely something > fishy. I suspect the inability to display Set members comes from the fact that the deb

Re: Obtaining a value from a hex representation

2016-01-08 Thread Steve Mills
On Jan 08, 2016, at 03:58 PM, Carl Hoefs wrote: A user enters the hexadecimal representation of a number like "0x31C8FD" into a text field. The intValue of such strings is 0. Is there a Cocoa method (like .hexValue) to convert the hex representation string into a value? Either use NSScanner o

Re: Obtaining a value from a hex representation

2016-01-08 Thread Jens Alfke
> On Jan 8, 2016, at 1:58 PM, Carl Hoefs wrote: > > A user enters the hexadecimal representation of a number like "0x31C8FD" into > a text field. The intValue of such strings is 0. Is there a Cocoa method > (like .hexValue) to convert the hex representation string into a value? -[NSScanner sc

Re: Obtaining a value from a hex representation

2016-01-08 Thread Quincey Morris
On Jan 8, 2016, at 13:58 , Carl Hoefs wrote: > > Is there a Cocoa method (like .hexValue) to convert the hex representation > string into a value? There are the ‘scanHex…’ methods in NSScanner. It’s a bit annoying to set up, but if you packaged it as a function it wouldn’t be bad. OTOH, if you

Re: Obtaining a value from a hex representation

2016-01-08 Thread Carl Hoefs
On Jan 8, 2016, at 3:16 PM, Steve Mills wrote: > > Either use NSScanner or strtol if you have char* (or strtoll if it's longer > than 8 hex chars). > Sent from iCloud's ridiculous UI, so, sorry about the formatting > Hadn't thought to use NSScanner, though it appears a bit overkill. strtoll()