objective-c

How to control the text color of an NSTextField when it is displaying a placeholder marker?

When the NSTextField (Label) is bound to a controller selection with bindings, and I have specified placeholder values for the Multiple Values Marker, No Selection Marker, etc it draws the text with a gray color that does not show up well on a dark background. Is there a way to change the text color it uses to display the placeholder te...

How to set/corrent the resting position of UIScrollView contents after it has scrolled.

I am implementing a view similar to a Table View which contains rows of data. What I am trying to do is that after scrolling, each row snaps to a set of correct positions so the boundaries of the top and bottom row are completely visible - and not trimmed as it normally happens. Is there a way to get the scroll destination before the sc...

UIImageView drifting on viewDidLoad

I am programmatically adding a UIImageView and a UILabel to multiple screens in a program I'm working on. As such, I've written a UIViewController that contains the code to load up the UIImageView and UILabel in viewDidLoad, along with a timer to update the contents. I use this view controller as a superclass for any views that need th...

Talking head library for Mac OS X

Is there a "talking head" library for Mac OS X / Cocoa / Objective-C? Specifically the ones that simplify translating spoken text into visemes / facial expressions? Microsoft has "Microsoft Agent" as part of their Text to Speech API, does the Mac has a worthy competitor for this feature? ...

Populating NSImage with data from an asynchronous NSURLConnection

I have hit the proverbial wall trying to figure out how to populate an NSImage with data returned from an asynchronous NSURLConnection in my desktop app (NOT an iPhone application!!). Here is the situation. I have a table that is using custom cells. In each custom cell is an NSImage which is being pulled from a web server. In order to ...

Suggest the best way of initialization of array ( or other objects ) .......

Hi, I am a bit confused in the following two ways of initialisations..... Way 1: - (void) myMethod{ NSArray *myArray = [[NSArray alloc] initWithObjects:obj1,obj1,nil]; [self setClassArray:myArray]; [myArray release]; } Way 2: - (void) myMethod{ NSArray *myArray = [NSArray arrayWithObjects:obj1,obj2,nil]; [self setClas...

Why do I need to type-cast an object when sending it an "isKindOf:" message?

If I'm trying to find out if an object is a type of a certain class (or any of that class's descendants), it seems that I should use "isKindOf:" if ([foo isKindOfClass:[bar class]]) {...} But the compiler gives me a warning "invalid receiver type 'void *'". This goes away if I cast "foo" to NSObject...or any other class! No matter w...

Detecting the use of private APIs

I'm being rejected on the App Store for using private instance variables in my app. The ivars I am supposedly using are most definitely not being accessed in my code, but I am using one or two static libs from third parties. How would I test whether these could actually be the offenders? Update: Apple is accusing me (and 3rd party libs...

Class not receiving delegate notifications

I have created a class (TestAccel) that implements UIAccelerometerDelegate. I have a private var in this class for UIAccelerometer. UIAccelerometer *accel; The class init looks like this: - (id) init:(id)actOnThisInstance{ [self init]; accel = [UIAccelerometer sharedAccelerometer]; accel.delegate = actOnThisInstance; return self; } ...

Convert bitmap to PNG or JPG using Objective C

Anyone knows how to convert a bitmap to PNG or JPG using Objective C assuming I have CGImageRef imageRef; ...

Object instance memory management.

This is a follow on from another question, my question is regarding the use of the retain/release in main(). From my understanding in this simple example the retain/release statements are not needed. BUT in more complex situations its best practice to add them as it ensures that the planet instance is not released unexpectedly. +(Planet...

Use ZIP-archives to store NSDocument data

I noticed that Apple started using zip archives to replace document packages (folders appearing as a single file in Finder) in the iWork applications. I'm considering doing the same as I keep getting support emails related to my document packages getting corrupted when copying them to a windows fileserver. My questions is what would be ...

How to use the first character as a section name

I'm using Core Data for a table view, and I'd like to use the first letter of each of my results as the section header (so I can get the section index on the side). Is there a way to do this with the key path? Something like below, where I use name.firstLetter as the sectionNameKeyPath (unfortunately that doesn't work). Do I have to gra...

game development for iPhone.

hi everyone. I am developing a game called moving together for iphone. The game is, there is a line centre, and 2 men standing back to back each other. Now I use 2 fingers to move them, go far from each other. But remember, there is a rope tied both of them. Now They have to move at the same time and at the same speed. If one of them mo...

Class Method Instance Scope?

My question is regarding the scope of the object created in +planet. I have been told that "autoreleased objects will stay around for the duration of the method/function they were created in" In my example I am assuming that the scope for the planet instance is within main() and not within the method where I do the initial alloc/init? +...

NSLog and Core Data

I have three Classes for which I am extending NSManagedObject (I know this isn't required but I wanted the property notation). Theses Classes are QuestionSet, Question and Answer. My data model is setup so that there's a many to many between them like so: QuestionSet <<->> Question <<->> Answer. I load up everything from a server and it ...

When is the right time to change the datasource for a UITableViewController

After rendering a UITableView with a given datasource, I want to be able to switch to a different one prior to calling reloadData. Tried doing it in the method - (void)viewDidAppear:(BOOL)animated; but as far as I can see this isn't called when all the visible cells are rendered. By placing a breakpoint it seems as if nothing is act...

Programmatically turn on bluetooth in the iphone sdk?

I have seen a lot of questions about this but no one actually gives a real answer (frameworks to import, actual code etc). They only say with a private api and that will get your app rejected from the app store. I am aware that use of a private api will get my app rejected by I was wondering how to do it for personal use. (iPhone SDK 3....

Most efficient way to do 22 different builds

I'm getting close to finishing my first relatively simple Xcode project (a custom installer) and I need to do 22 builds. Yes that wasn't a typo! What's different on each build is the PRODUCT_NAME, a source file in the bundle Resources folder and a variable that says whether the software is a trial version or not. From what I've read so...

transparent process creation for cocoa components

I have an application A which may or may not need to spawn an application B and will communicate with it using remote messaging (via NSConnections etc.). While i know how to do this if B is started first, i wonder: What is a clean cocoa-based approach of transparently starting B on demand? (For those familiar with COM, i am effectively...