Tag: cocoa

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

How do I escape special characters in an NSString using RegexKitLite?

I’m constructing a regular expression that uses strings input by the user but the strings might contain special characters such as . \ or * and I want those to be treated as literals and not interpreted by their special meanings in the regex. I’ve tried this: NSString *word = [input stringByReplacingOccurrencesOfRegex:@”(\\P{L})” withString:@”\\$1″]; but the […]

Can a NSDictionary take in NSSet as key?

I know you can use any object as key for NSDictionary but the problem is will it be able to retrieve the correct value? Support I have an entry where the key = {1,3,5} and value = { @”hello” }. Will I be able to retrieve from this dictionary entry by passing in the set […]