Tag: cocoa

Drag and Drop – Is it possible to get the URL?

I implemented a simple drag and drop. The main purpose is for users to drag and drop images from a browser. Is it possible for me get the URL that this image was dragged from? So lets say, I am on SO and I drag and drop the logo. Is there a way for me […]

Are @synchronized blocks guaranteed to release their locks?

Assume these are instance methods and -run is called. Is the lock on self released by the time -run returns? … – (void)dangerous { @synchronized (self) { [NSException raise:@”foo” format:@”bar”]; } } – (void)run { @try { [self dangerous]; } @catch (NSException *ignored) {} } …

Subclassing NSPredicate to add operator

Cocoa defines predicate classes (NSPredicate, NSExpression, etc.) which “provide a general means of specifying queries in Cocoa” Predicate Programming. This set of classes describes what I need but with one little short-coming : I’d like additional operators. NSComparisonPredicate already handles 14 operators (NSPredicateOperatorType) but I would like to add, say, temporal operators… or operators to […]

Create NSBezierPath from bitmap outline

I would like to create a NSBezierPath object which corresponds to the outline of an arbitrary bitmap image. All my images are png solid monochrome shapes with transparent backgrounds. Here is an examplee: I want the bezier path of the outline of the shape. What is the bast way to achieve this?

Layering Cocoa WebView – Drawing on top?

webview in core animation layer The only other thread I can find is the above which doesn’t necessarily fit my needs. Is there a reliable way to simply draw a view on top of a webview? I’ve tried to layer a regular NSView on top of WebView, and it draws right at first, but any […]

Objective C – Subclassing NSArray

I am trying to subclass NSArray, but it crashes the app when trying to access the count method. I know that NSArray is a class cluster. But what does this mean? Is there a work around to be able to subclass an NSArray? I know that I can simply subclass NSObject and have my array […]

objc_getProtocol() returns NULL for `NSApplicationDelegate”?

I’m trying to use the objc_getProtocol() function to get a reference to the struct representing the NSApplicationDelegate protocol: Protocol *protocol = objc_getProtocol(“NSApplicationDelegate”); However, for some reason, this always returns NULL. Other protocols such as NSObject, NSCoding, NSTableViewDelegate, and NSTableViewDataSource work fine. Is there something special about NSApplicationDelegate, or am I doing something wrong?

Key-Value Coding

I had a straight forward approach of turning Key/Value pairs of an XML excerpt into an NSDictionary when I started a simple iPhone application. The problem is, I need to turn those NSDictionary’s instances that once populated my UITableView’s into custom classes because they require behavior and additional complexity. The problem here is that now […]

Am I right in saying initWithNibName:bundle is used to manually load nib files and that initWithCoder would be used as an alternative?

I can’t use initWithNibName:bundle seeing as I’m now using the latest XCode (5). After some research I found an alternative: initWithCoder. Example: – (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self){ // code here } return self; } What I’m trying to understand is how this is an alternative to initWithNibName? Currently studying with […]

Binding search field and table view in cocoa

I have a nstableview. I would like to filter the results based on the characters entered in a search bar in OSX. So how do i bind the table view and the search field in OSX not in IOS? 🙂 Thanks.