cocoa

NSView not removing from superview

I have an NSView (we'll call it view1) that is from an NSViewController. The Super view (which we'll call view2) is located inside an NSWindowController. The problem is, I can add view1 to view2, but I can't remove it. ...

How to bundle a ruby package into an [Objective-C] cocoa application?

I'm trying to figure out how I could bundle a package, written in Ruby (Sass) into a Cocoa application (Objective-C, not Ruby Cocoa) for me to execute (via NSTask is fine, unless there is an easy way to bridge ObjC<->Cocoa that I'm not aware of). The Sass package is something you have to install, using "gem install" or "rake install" --...

How to make the first text field in NSCollectionView get default focus?

I have a NSCollectionView (MyCollectionView) on main window, each collection view item (MyCollectionViewItem) contains a text field inside it, so basically it looks like this: |---------MyCollectionView---------| | | | |----------------------------| | | |textfield | | | |--...

iPhone - get number of days between two dates.

I'm writing a GTD app for the iPhone. For the due tasks, I want to display something like "Due tomorrow" or "Due yesterday" or "Due July 18th". Obviously, I need to display "Tomorrow" even if the task is less than 24 hours away (e.g. the user checks at 11pm on Saturday and sees there's a task on Sunday at 8am). So, I wrote a method to ge...

App crashes on i386, works on x86_64

Hi, I tried switching architectures in my Xcode project today, because I was about to use low level QuickTime stuff that's not yet ported to 64 bit yet. When i compiled before on x86_64 my app ran just fine. Then i switched the arch to i386 and boom, my app keeps crashing on startup. The weird thing is, the stack tracke has nothing to ...

NSMutableArray with Struct

Hi, i like to make an array out of an typedef struct i have. It works fine when i work with a FIXED array size. But just to be open for bigger arrays i guess i have to make it with nsmutable array. But here i dont get it run //------------ test STRUCT typedef struct { int id; NSString* picfile; NSString* mp3file; NSStri...

Where to look up the date format specifiers used in cocoa / cocoa touch?

For example: [dateFormatter setDateFormat:@"yyyy-MM-DD HH:mm:ss"]; I guess there's a list somewhere that shows all those date format specifiers, but can't find any. The NSDateFormatter docs seem to not mention these. ...

Trying to build ConnectionKit example (but failing)

Hello, I've got the latest(?) ConnectionKit library by doing: svn co http://opensource.utr-software.com/source/connection/tags/1.2.3/ Then went into the dir (1.2.3), opened Connection.xcodeproj with Xcode, set Mac OS X 1.5 | Release | Framework to build the framework -> Build successful. Then went into 1.2.3/Example, opened Connecti...

Cocoa Selector Question

hi, I have a question on how to use a selector with multiple parameters. I need to toggle this: -(void)openBackupNamed:(NSString *)name using this: [backupList addItemWithTitle:file action:@selector(openBackupNamed:) keyEquivalent:@""]; I know that there is the withObject: parameter for these cases, but I can't do this in the a...

NSAppleScript Wont Work.

Can someone please tell me why this won't work? NSAppleScript* playPause = [[NSAppleScript alloc] initWithSource: @"\ tell application \"System Events\"\n\ tell application \"Final Cut Pro\" to activate\n\ keystroke \" \"\ end tell"]; I get the error "Expected ':' ',' ';' '}' or 'attribute' before '=' token". WT...

Drawing an "NSView" to a Custom-View - How? Am I taking the right approach?

I'm using Objective-C and Cocoa, whilst developing for Mac OS X - so not the iPhone/Cocoa Touch. (That said, I'd be interested if it was the same procedure for the iPhone) I'm working on a preferences window for a simple app. I have a NSWindow with a toolbar - there are 5 different items on the toolbar, all of which need to bring up a d...

General C/Objective C Question

I was going through Apple's documentation & I saw something like this (void (^)(void)). Can somebody explain what this statement means. ^ is XOR right... void XOR void doesn't makes much sense to me ...? There was also something like (void (^)(BOOL finished)) ...

NSOutlineView, NSTreeController and a heterogeneus hierarchy

Hello all, In page 40 of Marcus Zarra's Core Data book, he suggests that, since NSTreeController requires the same key for accessing all the objects in the hierarchy (for example, children) and that could imply less meaningful relationship names, you can write additional accessors for the desired relationships. I think that this is a gr...

How to pass NSTimeInterval object to detachNewThreadSelector withObject parameter?

I'm still new to Objective C syntax, so I might be overcomplicating this, but I can't seem to figure out how to pass an NSTimeInterval to a thread. I want to initiate a thread that sleeps for x seconds parameter sent from main thread as follows: [NSThread detachNewThreadSelector:@selector(StartServerSynchThread) toTarget:self withObje...

Compare two NSDates

How can I compare two NSDates and return the amount of time between them. For example: 2010-06-20 14:29:41 -0400 2010-06-20 14:53:29 -0400 should return something like: 23 or 24(minutes), rounding the seconds because I don't really need the seconds. ...

NSMutableSet and NSArray sorting, how to keep them consistent?

I'm trying to make an array of objects in random, non repeating order. Using NSMutableSet for the heavy lifting as recommended here: http://stackoverflow.com/questions/2141121/how-to-check-repetition-of-numbers-in-an-array I'm dumping them into an NSArray after creation to access them, but the NSArray doesn't stay in the order I placed ...

Cocoa - subviews not showing after being added

Im trying to add some subviews to a container (container is a NSView derived class, and subviews are some NSImageView objects). Since the code is messy right now due to trying different stuff, i wont paste it all for the time being. This is the part where i add the subviews: NSImage *tileImage; tileImage = [[NSImage alloc] initWithCont...

HelperApp unable to read user defaults from PrefPane

My project is composed by a PrefPane to set user defaults and a HelperApp that's running in background. Both are accessing the shared preferences plist file through CFPreferences functions. Basically the HelperApp is a CFRunLoopSourceRef: when it's triggered by power source events, it reads user defaults from the preferences plist and r...

Draw over screen with Quartz

Hi, I'm trying to work out what the best way to draw over the top of all other items on the screen on OS X. I don't want to impede the user's ability to interact with their applications, but want to 'annotate' them. I want to be able to draw up to 20 different annotations. The top half of this screenshot from Gizmodo happens to nicely s...

KVC with NSArrays of NSArrays

I have an array of arrays that I want to use KVC on (at least I think I do -- it seems like the most straightforward way) but I can't figure out how to create keypaths for individual array indexes. My array looks like this NSArray [ NSArray[0, 1, 2, 3], NSArray[4, 5, 6, 7], NSArray[8, 9, 10, 11] ] What I want to do is get the maximum...