Singleton or class methods?

2014-09-13 Thread Trygve Inda
I have a project that involves several different targets. Included in all this is a set of related utility methods that need to be used by different sections of the code. I am wondering how is the best way to do this so that I don't have the same utility methods written in different places. 1. I

Re: Singleton or class methods?

2014-09-13 Thread ChanMaxthon
Why not use straight C functions? Sent from my iPad On Sep 13, 2014, at 20:45, Trygve Inda cocoa...@xericdesign.com wrote: I have a project that involves several different targets. Included in all this is a set of related utility methods that need to be used by different sections of the

Re: Singleton or class methods?

2014-09-13 Thread Ken Thomases
On Sep 13, 2014, at 7:45 AM, Trygve Inda cocoa...@xericdesign.com wrote: These methods are used to convert between an NSScreen, CGDirectDisplayID, io_service_t, and a few other ways of dealing with screen identification. So a category on NSScreen is not going to work since in some cases an

Re: Singleton or class methods?

2014-09-13 Thread Alex Zavatone
I use a singleton for variable storage, a utility class for methods I want to call from anywhere and everywhere. On Sep 13, 2014, at 8:45 AM, Trygve Inda wrote: I have a project that involves several different targets. Included in all this is a set of related utility methods that need to

Re: Singleton or class methods?

2014-09-13 Thread Jens Alfke
I would go with class methods. Apple's APIs tend to use instance methods (NSFileManager, NSNotificationCenter, etc.); the benefit of those is that you can have multiple instances with different state (like delegates), or different behaviors. The doesn't seem like it's relevant to your case,

Loading image resources

2014-09-13 Thread Charles Jenkins
Hi, everyone. In my project’s images.xcassets, I created three image sets with these names: Folder SinglePage MultiPage Each one contains a single PNG image. Now I’m trying to load them into NSImages. Here’s what doesn’t work: let folderImage: NSImage let singleDocumentImage: NSImage

Re: Loading image resources

2014-09-13 Thread Quincey Morris
On Sep 13, 2014, at 12:28 , Charles Jenkins cejw...@gmail.com wrote: After calling bundle.pathForResource:ofType:, imageName is nil. I think what I’m doing is what the Resource Programming Guide says to do. How am I getting it wrong? a. Yes, but did you check whether bundle or imageFileName

Re: NSUserDefaults not sticking

2014-09-13 Thread Rick C.
1. Only certain ones that I know of 2. At application launch 3. No 4. I think Mavericks but not 100% certain 5. For the affected users yes 6. Not sure about this could check 7. Upon my request yes 8. Not sure would have to check On Sep 11, 2014, at 3:21 PM, Bavarious bavari...@icloud.com

Reset dispatch_once_t if the initialization failed?

2014-09-13 Thread Daryle Walker
I’ve seen bog-standard code to initialize a shared instance like: + (SomeSingleton *) sharedInstance { static SomeSingleton *sharedInstance = nil; static dispatch_once_t onceToken; static dispatch_once_t onceToken; dispatch_once(onceToken, ^{

Re: Reset dispatch_once_t if the initialization failed?

2014-09-13 Thread Kyle Sluder
On Sep 13, 2014, at 9:14 PM, Daryle Walker dary...@mac.com wrote: I’ve seen bog-standard code to initialize a shared instance like: + (SomeSingleton *) sharedInstance { static SomeSingleton *sharedInstance = nil; static dispatch_once_t onceToken; static dispatch_once_t

Re: Loading image resources

2014-09-13 Thread Charles Jenkins
*Sigh* I seem to make a typo every time I post to this list. Of course I meant that the imageFileName returned by the API call is nil. -- Charles Jenkins On Saturday, September 13, 2014 at 5:12 PM, Quincey Morris wrote: On Sep 13, 2014, at 12:28 , Charles Jenkins cejw...@gmail.com

Re: Loading image resources

2014-09-13 Thread Quincey Morris
On Sep 13, 2014, at 21:33 , Charles Jenkins cejw...@gmail.com wrote: Of course I meant that the imageFileName returned by the API call is nil. Ah, OK, but you still need to verify that everything is in place. For example, if you forgot to add the asset folder to the target, the image files