Tag: cocoa

String comparison for localization

What is the difference between NSString‘s localizedCaseInsensitiveCompare: and localizedStandardCompare: methods? I read the reference but did not get a proper idea of which one to use.

Implementing drag and drop in NSTableView

Can anyone help me to implement drag and drop in an NSTableView? I used this code below, but these methods are not getting called during execution. – (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard { // Copy the row numbers to the pasteboard. NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes]; [pboard declareTypes:[NSArray arrayWithObject:@”.gif”] owner:self]; [pboard setData:data forType:@”.gif”]; return YES; […]

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], […]

Anyway to make a (wrapping) NSTextField write a carriage return upon pressing return key?

I want to use a wrapping text field that can potentially contain carriage returns in my app. Is there any way to force the NSTextField object to write a carriage return into the text area instead of sending its action to its target when the Return key is pressed?

Is there any way of knowing how many NSUserNotifications there are in NSUserNotificationCenter?

Is there any non-private way of knowing how many notifications there are in the Notification Center (NSUserNotificationCenter) in Mountain Lion? Not just notifications from my app, but from all apps. So, to sum things up, what I want to do is to retrieve the number of notifications displayed here: I’ve tried to search around, but […]

NSCollectionView How to scroll to selected item

I programmatically select a item in my NSCollectionView. The item is selected as expected but the view doesn’t scroll automatically to this item. [collectionView setSelectionIndexes:[NSIndexSet indexSetWithIndex:compt]]; How to scroll to the selected item ?

How to use NSWorkspace launchApplicationAtURL?

I tried to run equivalent of “TextMate foo.txt” using launchApplicationAtURL. The name of binary is “TextMate”, and I have one parameter. I tried the following code, but it doesn’t seem to work. // find the textmate NSURL * bURL = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@”com.macromates.textmate”]; NSWorkspace * ws = [NSWorkspace sharedWorkspace]; // find the parameter NSString * […]

Floating autolayout iOS/OSX

I have a need for floating autolayout. I find that its quite hard problem to solve but i think it can be done by using some of the tips described here: http://www.objc.io/issue-3/advanced-auto-layout-toolbox.html Maybe someone have already tried solving such problem or would like to try it. So here is the challenge: nicely floated views which […]

NSFileManager list directory contents excluding directories

Is there a way to tell the -[NSFileManager contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:] method to exclude directory names when gathering the contents of a directory? I have a tree view showing folders and want to show ONLY files in the table view, but I can’t seem to find a key or any other way to exclude folders. I suppose […]

Call Javascript Function From iOS Webview in Angularjs App

My problem is that when I try to call a javascript function that exists in my AngularJS app from within a UIWebView that function is not recognized. When I call the function in a typical html structure the function is recognized as expected. Example provided below: OBJECTIVE-C: – (void)viewDidLoad { [super viewDidLoad]; // CODE GOES […]