cocoa

Calling -init multiple times in Objective-C

What happens when you call -init multiple times on one object, are there some hidden side effects? Can you assume that no additional memory is allocated? Would anything go against such an idea? ...

Sparkle Framework: How to change application name?

I have a Cocoa application for which I've changed the name. I'm using the excellent Sparkle Framework (http://sparkle.andymatuschak.org/) to provide updates to my users. Unfortunately, it appears that Sparkle doesn't support application name changes out of the box. I'm hoping there is some hack so that I can provide users who already ha...

Adding elapsed time in Cocoa

In Cocoa, how would I add times for example: 1:30 (one hour and 30 minutes) 1:25 (one hour and 25 minutes) 2:15 (two hour and 15 minutes) = 5:10 but when I get to greater then 24 hours I do not want it to go, one day x hours and y mins, I want it to continue adding the hours e.g. 25, 26, 27 ... 100 hours etc. Is there already an imple...

Custom NSWindow drawing

I want to draw an NSWindow that looks similar to this: http://vibealicious.com/site/apps/notify/screenshots/mainUIFull.png In that it has a typical NSWindow appearance with the bottom bar and such, but instead of a title bar at the top, I want to draw a little arrow. Is there a simple way to do this? Do I have to draw the entire wind...

Cocoa app - can I integrate Amazon Product search within my cocoa app

Happy new year every one. I have integrated Amazon Product Search using the widgets they provide within my website. I also want to integrate it within my cocoa app. Any idea how this can be done? Do they have an API/web service which we can use in the cocoa app? Thanks.. ...

In Cocoa, how is the id type defined?

This question is out of pure curiosity. How does Cocoa define the id type? Is it just a typedef for a void *? Also, if you know which header file it is defined in, I would be interested in taking a look. ...

Hacking the NSDocument architecture

I'm working on creating an NSDocument-based app with tabs for documents. I have found that it wasn't really designed for this. Apple designed the architechture to allow multiple windows for a single document but not the other way around. I have it basically working but I have started to run into weird issues. For example, when a window i...

Can this loop be optimized?

I'm at the debugging/optimization phase with an iPhone app. I have one bottleneck left - the only place where the program has a noticeable lag, and it's in the following loop: (By the way, I've renamed the vars with letters and types. (The real names are much more human-readable in the actual app, but make little sense out of context, so...

How to handle with a default URL scheme

Hi. I want to build URI (or URL scheme) support in my app. I do a LSSetDefaultHandlerForURLScheme() in my + (void)initialize and I setted the specific URL schemes also in my info.plist. So I have URL schemes without Apple Script or Apple Events. When I call myScheme: in my favorit browser the system activates my app. The problem is,...

Displaying row index in an NSTableView bound to NSArrayController

I have an NSTableView which is bound to an NSArrayController. I would like to have one of the table columns showing the index of the table row. This is easy enough to do when you implement NSTableDataSource yourself but I can't figure it out with a bound table view. I guess I'm looking here for something like the @count key path which gi...

NSMenuItem Text Field Highlight Problem

Hi, I am creating a Status Bar application which requires a URL being entered in a text field. The text field is a subview of the NSMenuItem. The problem I am facing though is that the value of the text field cannot be changed and only "indirectly highlighted" (it's not the normal blue highlighting but a grey one and only occurs when do...

Animating an NSView in from Below.

How would I animate an NSView in from below. I know there are tutorials like Marcus Zarras which shows how to change from one view to another, but how would I animate in a view which isn't going to replace another view. ...

Is garbage collection used in production quality Cocoa apps?

I'm mainly wondering about the affect that garbage collection would have on performance. Is the use of garbage collection frowned upon for release apps? Another concern that I can think of is that using garbage collection could lead to sloppier programming. Do you use garbage collection in your apps? ...

NSString sizeWithAttributes: content rect

How do I get a NSString's size as if it drew in an NSRect. The problem is when I try -[NSString sizeWithAttributes:], it returns an NSSize as if it had infinite width. I want to give a maximum width to the method. Is there any way of doing so? (BTW: Mac OS, not iPhone OS) Thanks, Alex ...

How do I unlink and remove a related object in CoreData

I have a core data entity which has an exclusive one to many relationship with another entity. This relationship is supposed to be a basic containment the first entity contains one or more of the second. An instance of the second entity can only be contained in one of the first entities. I want to be able to remove all the contained ent...

iPhone Currency input using NSDecimal instead of float

Hello, iPhone/Objective-C/Cocoa newbie here. Based on a number of posts on stackoverflow, I have cobbled together an IBAction that I'm using in a basic iPhone calculator app that I'm building. The IBAction works with the numeric keypad to allow entry of decimal numbers without having to enter a decimal point. I am trying very hard to ...

Get pixels and colours from NSImage

I have created an NSImage object, and ideally would like to determine how many of each pixels colour it contains. Is this possible? ...

what is layer in core animation

In core animation or in App kit When we say layer-backed view or simply add a layer in the view,then actually what we mean by the layer. ...

Making a window pop in and out of the edge of the screen

I'm trying to re-write an application I have for Windows in Objective-C for my Mac, and I want to be able to do something like Mac's hot corners. If I move my mouse to the left side of the screen it will make a window visible, if I move it outside of the window location the window will hide again. (window would be pushed up to the left s...

Problem with NSObject init method

Hi, I have a problem with the init() method of a standard NSObject. I wrote a class (EFAPersistence) which is a subclass of NSObject. EFAPersistance has a attribute called efaDatabase. EFAPersistence.h @interface EFAPersistence : NSObject { FMDatabase * efaDatabase; } @property (assign) FMDatabase * efaDatabase; Everytime an inst...