cocoa

Does Core Data exist on the iPhone? Or how would you save Data on the iPhone?

Lets say I make an App that enables users to make short notes and write things down. Is there Core Data on iPhone OS too? Or how else would you save that data in iPhone? ...

The file an IconRef comes from

Is there any way to find out the .icns file an IconRef refers to or has been loaded from? Or even the id of the containing bundle if there is one? I understand that not all icons are loaded directly from a file (composite icons for example) so this wouldn't work all the time. The question I'm trying to answer is "Where does the icon th...

Should I save strings returned by NSLocalizedString()?

I'm working on an iPhone app that we're localizing in both English and Japanese for our initial release. We frequently call NSLocalizedString() to load the appropriate localized string for display. Is it generally better to save the localized strings in instance variables for the next time we need them, or am I micro-optimizing here an...

Which technologies/concepts do you suggest I learn before creating an iPhone game?

Sorry if this is a broad question, but other than Objective-C, Cocoa, and OpenGL ES, what technologies or concepts would you suggest I read up on before writing a game for the iPhone? I'm a beginning game developer and need all the help I can get :) ...

Traversing multiple Core Data objects using NSPredicate

I am having a problem with a Core Data model in Cocoa. It's probably a fairly basic problem. A section of my Core Data model is shown below. Given the value of a cell property in the OutputCell entity, I want to return the relevant HistogramBar. I'm using the following Predicate but it just returns an empty array. I've managed to ge...

How to concatenate char and string on iPhone?

I want to add some marks to separate some strings. How to add a char to a string? e.g. add '\x01' to "Hello", add '\x02' before "World" and add '\x03' after "World". So I can create a string "\x01 Hello \x02 World \x03" which has some separate marks. ...

When to release a NSString in iPhone

I have the following method -(NSMutableArray *) getPaises { NSMutableArray * paises; paises = [[NSMutableArray alloc] init]; while( get new row ) { NSString *aPais = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]; [paises addObject:aPais]; } return paises; }...

Is there any reason to retain a scheduled NSTimer if you don't need to invalidate it?

I'm going back over some crufty code to tidy it up and I see I've been retaining NSTimers returned from scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: and storing them in a field - then releasing and nulling the field when it fires. In some cases I use the timer to send an invalidate message to it later - but in many ca...

How to properly work (retrieve values) with NSUserDefaults

Hi all, I have a simple method in my code which looks like the following: - (BOOL)isFirstTimeLogin { NSString *t_gName = [NSString stringWithFormat:@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:kGroupIdentifierKey]]; if ([t_gName isEqualToString:@""] || t_gName == nil) { DLog(@"LoginViewController, m:::isFi...

What is double star?

So, I saw this: error:(NSError **)error in the apple doc's. Why two stars? What is the significance? ...

Wait for [NSAlert beginSheetModalForWindow:...];

When I display an NSAlert like this, I get the response straight away: int response; NSAlert *alert = [NSAlert alertWithMessageText:... ...]; response = [alert runModal]; The problem is that this is application-modal and my application is document based. I display the alert in the current document's window by using sheets, like this: ...

How do you draw text in a custom view using Objective-C?

I've figured out how to use the NSBezierPath class to draw shapes in the drawRect function of my custom view class, however I can't seem to figure out how to draw text. The following code is what I have so far for drawing the text (located in the drawRect function): NSText *text = [NSText new]; [text setTextColor: [NSColor yellowColor]]...

Binding a custom NSView: Does it demand creating an IBPlugin ?

I have created a subclass of NSView to draw an image as a pattern: @interface CePatternView : NSView { NSImage* image; id observableObjectForImage; NSString* keyPathForImage; } @end I implemented the following to expose bindings: + (void)initialize { // Expose the "image" binding to IB. [self exposeBinding:@"i...

Add custom certificate for iphone HTTP API

Hi, Is there any way to bundle a certificate in my application - and then use that to perform HTTP GET/POST using a NSURLRequest? I.e. the certificate should not be used for other HTTP traffic on the device, only by my application. Cheers ...

Subclassing a NSTextField

First off; I'm a COMPLETE newbie at Cocoa, so please bare with me for asking what I am sure is an inane and utter newbish question. My situation is as follows: I want to expand on the functionality of NSTextField. AMong the things I want to achieve is: Changing the look and feel of the caret. Detecting when the text reaches a certain...

Why does Cocoa return an empty string occasionally?

I have some code in my application that looks something like this: char *hash = (char*) sqlite3_column_text(get_bookmark, 0); NSString* postHash = [NSString stringWithUTF8String:hash]; This works for me every time; I've never seen it not work. Most of my users do not experience problems (as far as I know). However I find that postHash...

Monitoring user idle time

Developing a mac app, how can I tell whether the user is currently at their computer or not? Or how long ago they last pressed a key or moved the mouse? ...

How do you calculate the bouding rect for a string in Objective-C/Cocoa?

Using Objective-C/Cocoa how do you calculate the width and height required to draw a string based on a particular font? In C#/.Net you can do it like this: SizeF textSize = graphics.MeasureString(someString, someFont); Is there something like that available in Objective-C/Cocoa? ...

Register as Login Item with Cocoa?

Google gave me: http://developer.apple.com/samplecode/LoginItemsAE/index.html And I figured there must be a better way than using AppleScript Events. So I downloaded the Growl sources. They use the exact sources from that Apple developer article. Is there a better way? (I refer to Login Items in Accounts in System Preferences, ie. ma...

How to make an iTunes like (playlists, library) left-sided (collapsible) navigation bar?

I am talking about the navigation area on the left side of iTunes for Library and Playlists. I'm wondering if this is a built in class (which I couldn't find documented) or something custom implemented by Apple. I'm working an a mac application where I want to include that type of navigation. I want to allow people to "fold" the catego...