cocoa

Is there an API for the blue email address bubbles?

Hi! Is there an API that will let me reproduce the blue round email address bubbles easily? You see these bubbles in Mail on MacOS and on the iPhone. Thanks! ...

Integer Casting in dealing with strings in Cocoa

I have what I hope to be a pretty simple problem. I'm very simply trying to convert a char to it's lowercase version. Here's my code: - (IBAction)click:(id)sender { [outputLabel setText:[inputField text]]; NSString* textFieldString = [inputField text]; NSLog(@"String is %@", textFieldString); int textFieldLength = textF...

Easiest way to format a number with thousand separators to an NSString according to the Locale

I can't seem to find an easy way to do it. The exact thing I need is: [NSString stringWithFormat:@"%d doodads", n]; Where n is an int. So for 1234 I'd want this string (under my locale): @"1,234 doodads" Thanks. ...

Using CATransition with multiple Xib files on Iphone

I've been following this tutorial(www.vimeo.com/1450817) on using Multiple XIB files and I wanted more Transition animations besides flipping and Curling. I've also came across the CATransition class and I wanted to use it but all the tutorial that I've seen with it shows how to use it only if there are views in the same XIB file. so f...

How to convert NSInteger to int

hi, e.g. NSInteger called a [a value] is a EXC_BAD_ACCESS how to convert NSInteger to int ? (only small numbers < 32 are used) ...

Fastest way to programmatically open prefpane?

AppleScript was too slow, so I tried ScriptingBridge to open System Preferences.app and set the current pane, which is also too slow. Is there a faster way to do it? properly ...

How to conditionally use a new Cocoa API

In 10.6 Apple added +[NSPropertyListSerialization dataWithPropertyList:format:options:error:] and labeled the older +[NSPropertyListSerialization dataFromPropertyList:format:errorDescription:] as obsolete and soon to be deprecated. One way to use the newer call on 10.6 and above, and still run on earlier OS releases, would be something l...

How do I get the details of an application using Objective-C?

I have the following code to detect the current window. How can I get 1) application internal name, 2) location, 3) publisher and 4) description of the window/application? NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //Get info about the currently active application. NSWorkspace* workspace = [NSWorkspace share...

ABPeoplePickerView - How do I get it to scroll to a selected record?

I'm using the ABPeoplePicker in a Mac OS X application. I've hooked up a button that changes the selected record to the default 'Me' record. This works fine, and the record gets selected, but, I need to scroll the table to see the selected record. NSTableView has the -scrollRowToVisible:(NSInteger)rowIndex method, but I can't find anyt...

Open Directory directory domain name on Mac OS X

I can retrieve the logged in user name using NSUserName(), but how do I get the Open Directory "directory domain name" or other domain he is a member of? i.e. similar to the notion in Windows where a logged-in user is DOMAIN\USERNAME, where DOMAIN is his local machine, workgroup or Active Directory domain. ...

How do I flag a folder as being a package?

I used to think that folders needed to have an extension so that they are recognized as packages by the Finder. That extension would be declared in the owning application's Info.plist. Obviously there is another, more elegant way, but I can't figure out how it is done. E.g. the iPhoto Library is being treated as a package by the Finder...

Is it possible to Sort Arrays with custom objects containing String elements localized AND with correct Numbers in Cocoa Touch?

Assumed having the class Account with Name and accountNo both as NSStrings. I want to sort an Array of Accounts either by name or by accountNo. The sort should be done localized. If I use NSSortDescriptors as described in the Guides I have the option to pass localizedCaseInsensitiveCompare: to the Array, but the numbers are not sorted c...

CVDisplayLink instead of NSTimer

I have started to implement cvDisplayLink to drive the render loop instead of nstimer, as detailed in this technical note http://developer.apple.com/mac/library/qa/qa2004/qa1385.html Is it better to do the actual rendering within the displaylink callback itself, or should I instead call setNeedsDisplay on the view and let the main threa...

MacOS - howto change the SYSTEM temp folder (programatically) ?

we need to change the default SYSTEM temp folder for our multiplatform application. The systems default call for getting the SYSTEM temp folder should return the folder we have specified. On MS-Windows this is GetTempPath(). On MacOS the function is called NSTemporaryDirectory() I think. We need to do this because we are running multip...

How do I update a NSTableView when its data source has changed?

I am working along with Cocoa Programming For Mac OS X (a great book). One of the exercises the book gives is to build a simple to-do program. The UI has a table view, a text field to type in a new item and an "Add" button to add the new item to the table. On the back end I have a controller that is the data source and delegate for my NS...

Is if(obj && obj != nil) correct and necessary?

Two parts to this question 1) Is this understanding of what's going on correct? "if (obj)" is testing to see if the pointer is not 0x0, aka set to an integer memory address "if (obj != nil)" is comparing the memory address of the object to the memory address of the universal nil object 2) So in a situation where I don't know if a varia...

NSTextFieldCell vertical alignment, solutions seem to squash the horizontal alignment.

I have a NSTextFieldCell that I wish to display with middle vertical alignment. Thanks to an older question here and a blog entry I have two working solutions. However, both solutions seem to squash my ability to set the cell as right aligned. Can anyone help me make either of these solutions support both forms of alignment? Here i...

set/get fn-lock for a macos application

Does anybody know a way to set/get the fn-lock from an application so you don't have to press the 'fn' key to get F1, F2, etc. on a macbook or apple keyboard? I want to have it always on for my application but keep the standard behavior in the rest of the system. ...

Add shadow (recessed text effect) to Cocoa label without degrading text rendering quality

I'd like to create statusbar with text effect like in Safari or iTunes, i.e. recessed text. However, if I simply add shadow in Interface Builder using Core Animation panel, OS X's worst text rendering kicks in: What's the trick to get recessed text on a label and keep proper subpixel rendering? ...

Mac Dev - How to refresh view for 2d game?

If you see my other question, you'll know that I'm starting to try making simple 2d games on mac. There I was deciding which library to use (OpenGL or Quartz), but no matter what I'll have to use Cocoa to make it a nice Mac application, and for the window and the view (with OpenGL, NSOpenGLView). Obviously for a game, the view will have ...