cocoa

Checking if an object has been released before sending a message to it

I've only recently noticed a crash in one of my apps when an object tried to message its delegate and the delegate had already been released. At the moment, just before calling any delegate methods, I run this check: if (delegate && [delegate respondsToSelector:...]){ [delegate ...]; } But obviously this doesn't account for if the...

How to display a subview loaded from a separate NIB file

I'm developing a Cocoa desktop application that uses a source list in the style of iTunes: different elements in the source list cause the main content area to display different views. The content area is entirely filled with a (vertical) NSSplitView; on the left is an NSOutlineView source list. When the user selects an item on the left...

UITableViewCell is 1px shorter in didSelectRowAtIndexPath than cellForRowAtIndexPath

I have a UITableViewCell that I create in tableView:cellForRowAtIndexPath:. In that method I call: UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease]; NSLog(@"Cell height: %f", cell.contentView.frame.size.height); This gives me a return value of 44.000000. Then...

iPhone noob - setting NSMutableDictionary entry inside Singleton?

Yet another iPhone/Objective-C noob question. I'm using a singleton to store app state information. I'm including the singleton in a Utilities class that holds it (and eventually other stuff). This utilities class is in turn included and used from various view controllers, etc. The utilities class is set up like this: // Utilities.h...

How to load JPG file into NSBitmapImageRep?

Objective-C / Cocoa: I need to load the image from a JPG file into a two dimensional array so that I can access each pixel. I am trying (unsuccessfully) to load the image into a NSBitmapImageRep. I have tried several variations on the following two lines of code: NSString *filePath = [NSString stringWithFormat: @"%@%@",@"/Users/adam/D...

If NSString stringWithContentsOfFile is deprecated, what is its replacement?

I have some sample code from Tuaw which is probably 3 releases old ;) The compiler is issuing a warning that the method is deprecated, but I do not see that mentioned in the SDK docs. If it is deprecated, there must be an alternative approach or replacement method. Does anyone know what the replacement is for this method? The specifi...

Problems using a library in Xcode

Hi! I'm actually developping an application for iPhone and I need to use a library, initially dedicated to a Linux environment. Since I'm using a Mac (with Snow Leopard and Intel Core Duo), I guess it's possible to use this library in my app. My library has 3 files: a file .h, a file .a and a file .so (both .a and .so are in /Developer...

how to terminate cocoa app in applicationWillFinishLaunching delegate

I have to show the custom license Agreement dialog to the user before they start using my application.So, i have added new window in my mainMenu.xib and showing that window modally using [NSApp runModalForWindow:licenseWindow]; in applicationWillFinishLaunching: delegate by making my main window hidden using visible at Launch to unch...

Can we categorize photos in photolibrary?

Is there anyway to categorize photos in the photolibrary? I want to make different folders in my photolibrary like Friends,Family,US Trip,...etc. ...

UITabBarItem selection color

Is it possible to change the color of the active tab on iPhone's tab bar? By default it is blue and it is not working with my app's color scheme. ...

Cocoa : How do I catch drag operations initiated from an IKBrowserView?

So I've got an IKBrowserView all wired up and happily dragging my custom datatype (provided lazily via PasteboardItem) from one window to another, but now I'm interested in detecting when the user drops some data onto the trashcan. Cocoa's documentation says to check the return type of the drag operation itself, but how exactly do I do t...

Can NSLocale's NSLocaleCountryCode key be directly mapped to a TLD?

Hi, in my app i need to open a website with the corresponding TLD for that country. Lets say google.com, google.de, etc... But i don't know which country codes the're specifically using in NSLocale's dict. Can i assume that the lowercase version of NSLocaleCountryCode can be appended as TLD? Regards, Erik ...

detecting double free object, release or not release ...

Hello, If we have this code in our interface .h file: @interface CarModelSelectViewController : UITableViewController { NSString *fieldNameToStoreModel; NSFetchedResultsController *fetchedResultsController; NSManagedObjectContext *managedObjectContext; DataEntered *dataEntered; } @property (nonatomic, retain) NSString *fieldNameTo...

Problem in adding data to an array in Objective-C

I am grappling with adding an NSData object to a NSMutable array. The code is executing fine but it is not adding the objects in the array.The code is as follows: NSData * imageData = UIImageJPEGRepresentation(img, 1.0); int i=0; do{ if([[tempArray objectAtIndex:i] isEqual:imageData]) { [tempArray remo...

How to make a file invisible in Finder using objective-c

I need to hide the file in finder as well as in spotlight if possible using objective-c or using C calls. Thanks ...

Which are the most noteable things which make working with Core Data different than with MySQL?

One thing I have in mind is, that datasets in Core Data (or lets say: managed objects) have no ID like known from other databases such as MySQL. Also, they're not in a specific guaranteed order. What else makes Core Data much more "special" compared to working with a relational database like MySQL? Besides the whole object graph persist...

UIView animation VS core animation

I'm trying to animate a view sliding into view and bouncing once it hits the side of the screen. A basic example of the slide I'm doing is as follows: // The view is added with a rect making it off screen. [UIView beginAnimations:nil context:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:0.07]; [UI...

Cocoa nonatomic properties

When you look at some Objective-C code, you often see class properties defined as non-atomic. Why? Does it give you some performance boost when you're not working with threads, or is there some other reason? ...

Change the text color in webView

Is there a way to change the text color for entire webView? If it is could you provide me with some examples? ...

What's the correct way to represent a linear process in CocoaTouch (UIKit)?

I need to represent a linear process (think wizard) in an iPad app. In principle I could use a UINavigationController and just keep pushing new controllers for each step of the process. But this seems rather inefficient since the process I'm modeling has no notion of navigating backwards so all previous views would pointlessly stay aro...