cocoa

Check duplicate objects in NSMutableArray?

I am adding objects (NSNumbers in this case) to an NSMutableArray and I wanted to check what the best way is to check for duplicates in the array before adding. (i.e.) Number to add if (NSMutableArray does not contain Number) { add Number } EDIT: Many thanks, I had a good luck at NSArray this morning but totally missed "containsO...

How to set desktop wallpaper and screen-saver?

How to set desktop wallpaper and screen-saver from cocoa app? ...

Is this a safe/valid hash method implementation?

I have a set of classes to represent some objects loaded from a database. There are a couple variations of these objects, so I have a common base class and two subclasses to represent the differences. One of the key fields they have in common is an id field. Unfortunately, the id of an object is not unique across all variations, but wit...

Is it good practice to put private API in the .m files and public API in .h files in Cocoa?

Many of my classes in my current project have several properties and methods that are only ever called from within the class itself. Also, they might mess with the working of the class depending on the current state of the class. Currently, all these interfaces are defined in the main interface declaration in the .h files. Is it consider...

Selection Highlight in NSCollectionView

On some occasions my head just hurts from banging it against the Cocoa wall. Today is one of those days. I have a working NSCollectionView with one minor, but critical, exception. Getting and highlighting the selected item within the collection. I've had all this working prior to Snow Leopard, but something appears to have changed and ...

Dropping text by a line when pressing return key

Hi, I have drawn NSTextView object on NSView, which i added by calling addSubview method. When I enter text and press enter text i had entered come down by one line correspondingly. What can be the reason behind it, and how to cope with this problem. ...

How to avoid XCode framework weak-linking problems?

Hi, I'm building an application that takes advantage of Mac OS X 10.6-only technologies, but without giving up backwards compatibility to 10.5 Leopard. The way I do this is by setting the 10.6 SDK as the base SDK, weak-linking all frameworks and setting the deployment target to 10.5 as described in: http://developer.apple.com/mac/libr...

A way to forward events to multiple views with a NSCollectionView

Hi, I am trying to forward a keyboard event from the Collection View to all the views it contains. I've tried figuring out how to obtain an array of the views so that I could forward the event to each view, but I could not find a way to do this. I feel that I am going about this the wrong way. Any direction is appreciated. Thank you, ...

How to customize NSMenu like the Apple Pro Apps?

I want to customize a NSMenu with NSMenuItems, so does it looks like the Apple Pro Apps. But how can I customize a NSMenu? There is no draw method to change the appearance. If I set a NSView to a NSMenuItem, I can set the background color, but I will loose highlighting and menu handling. Furthermore the top and bottom cap of the NSMenu...

Display a number on the screen Iphone SDK

does anyone know how to display a number on the screen/iphone simulator? I can load the data and create a x/y graph. Now instead of showing the graph, I load the data value from a text file, and I want to display the number on the screen. Does anyone know what function i can use? NSString *data =[myText objectAtIndex:i]; output_data_val...

Cocoa contentsOfDirectoryAtPath: method failing with error for certain users - Mac OS X

Here's a snippet of the code: // Get into the data folder of it keychainPath = [keychainPath stringByAppendingPathComponent:@"data/default"]; DLog(@"Keychain data path: %@", keychainPath); // Define Filemanager NSFileManager *fm = [NSFileManager defaultManager]; // Catch any errors NSError *dataError = nil; // get all the files in t...

Tile more than 9 images with Cocoa.

I want to draw 15 images in drawRect: but the biggest I could find was NSDrawNinePartImage() I want 4 corners, top/bottom fill, and 3 rows between them (two side fills and a center fill) What is recommended here? NinePart + 2 * ThreePart? Or something else? ...

Turning an NSImage* into a CGImageRef?

Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an ...

Binding to NSTextField Cell not working, edited value resets to default

I'm working on a Core Data document application that dynamically creates NSTableColumns. The data cell type may be a checkbox, slider, etc. Programmatically binding to all cell types works, except for NSTextFieldCell. All NSTextFieldCells fail to bind, and after editing they return to their default value. This happens no matter if they'...

Cocoa - Timer object that can be started, suspended, resumed?

I'm looking for a repeating timer object that allows me to create it once and then suspend and resume it as needed for the lifetime of my application. I've seen documentation for NSTimer and although I think I can make it do what I want by building an abstraction on top of it that creates/invalidates timer objects multiple times, I was ...

Cocoa Browser Air missing iPhone docs. Can't find xcode DocSets?

I installed Cocoa Browser Air at home from the same installation file (for 2.4.1) that works fine at work. Its info for Mac OS X 10.6 looks OK, but there's nothing under either iPhone 3.1 or 3.2. I've installed the appropriate Documentation Sets in Xcode Preferences->Documentation, and I have an iPhone SDK, which is required to refer t...

NSArrays in NSArrays. A pointer problem?

I believe my problem involves pointers, a concept I often struggle with, but here's what I'm trying to do. I have six NSArrays. I want an additional NSArray comprised of these six arrays, so: self.arr1 = [NSArray array]; self.arr2 = [NSArray array]; self.arr3 = [NSArray array]; self.arr4 = [NSArray array]; self.arr5 = [NSArray array]; ...

Cocoa Webkit visit url without typing http://?

Is there a way to visit a website without typing http://? ...

Finding source of over release

Hi, I'm consistently seeing the same message sent in as a crash report from users of an app. It's clear that an object is being over-released but I'm unable to replicate it and I'm looking for tips on tracing the source of it. The relevant section from the crash report shows this: Application Specific Information: objc_msgSend() selec...

Arc text in iphone application

Hi all I want to bend the text that of UILabel from corner. It just like appear as arc or as following link. http://picasaweb.google.com/lh/photo/kfBzK4R4IlvyHfVywUNd1A?feat=directlink please suggest me, from where i start. any documentation,link, sample code. thanks amit battan ...