cocoa

removing/adding CALayers for GPU optimization

I have a layer backed view, I am trying to add subLayers roughly sized around 300 X 270 (in pixels ) to it, its that the, sublayers count may reach upto the 1000 to 2000 in number and not to mention each of sublayer is again scalable to roughly 4280 X 1500 or more for starters. So the problem is obviously that of a GPU constraint. afte...

Setting an object nil versus release+realloc

This is not a garbage collected environment I have a class instance variable which at some point in my runtime, I need to re-initialize with a different data set than it was originally constructed with. Hypothetically speaking, what if I have an NSMutableArray or an NSMutableDictionary, would it be more efficient to do something such a...

How do I create delegates in Objective-C?

I know how delegates work, and I know how I can use them. But how do I create them? ...

QTKit, opening input devices???

I'm trying to add two inputs to a QTCaptureSession in the following: mainSession = [[QTCaptureSession alloc] init]; BOOL success; NSError* error; QTCaptureDevice *videoDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:@"QTMediaTypeVideo"]; success = [videoDevice open:&error]; QTCaptureDevice *audioDevice = [QTCaptureDevice de...

How to set up HTTP connection in a special class?

I want to create a class to handle all the HTTP connection work for other classes(in order to avoid writing codes repeatedly). I call it ConnectionCenter(subclass of NSObject) and add the following codes to it: -(void)connect:(NSString *)strURL obj:(ConnectCenter *)objConnect { NSURLRequest *theRequest=[NSURLRequest requestWithURL:...

using frameworks in a command line tool

I've built a command-line utility (Foundation tool) in Xcode, using Cocoa. The tool makes use of a 3rd party framework. Everything works OK in Xcode, but how do I deploy this program? If I run the app from Finder, it can't find the library because it's looking in "../Frameworks/etc." Can I statically link in the 3rd party framework? ...

Creating a Core Data Inverse Relationship

I'm trying to write my first Cocoa app, and Core Data is making it difficult to model my data objects. I have two entities that I want to manipulate: Account and Transaction. Account has a human-readable name and that's about it. Transaction stores a monetary value, and references to two accounts called debitAccount and creditAccount (I'...

detecting fullscreen on mac

I am writing an IM client for Mac (in python, but an Objective C / Cocoa solution here is fine). I want to detect whether or not the user is currently watching a movie or playing a game in the foreground, or doing anything else that takes up the entire screen. If so, I won't play a sound when a new IM comes in, but if not, I will play th...

How to design a static class?

I want to create a special class for holding a lot of values like strName, strNo, intPassword...So that several other classes can modify the same value in this class. I want to use the dot syntax to call its properties like Values.strName = ...; I don't want to initialize the class everytime before I read/write its values because some o...

What is a referencing outlet?

I just recently upgraded my copy of Xcode 3 to Xcode 3.1, and I noticed something new in interface builder - the referencing outlet. Can anyone explain what referencing outlets are, and how they relate to mac development? ...

Cross-platform development - Go with a cross-platform UI toolkit or native on multiple platforms?

I'm looking for some arguments to pitch to my boss and fellow developers. We're currently finishing up the preliminary UI mockups and getting ready to move on to the next phases of development. In the meantime, I've been digging through the depths of the Carbon, Win32, and wxWidgets APIs attempting to make some of the controls have a...

NSMutableArray count always returns zero

I'm sure I'm doing something silly, but this is driving me crazy. I'm trying to loop through database results, create objects from those results, and add the objects to an NSMutableArray. I've verified via NSLog calls that the data is being correctly read from the database and copied to the object, but the count for the NSMutableArray a...

Cocoa/iPhone: How do I create a Simplified Chinese localization of my app?

I'm in the middle of localizing my iPhone app, and I've gotten English, French, German and Japanese localizations working without any problems. Now I'm trying to get a simplified chinese localization working, and no matter what I try, the chinese .lproj bundle just won't be used when I have the phone set to simplified chinese. One probl...

How do I dismiss a sheet with the escape key?

My app displays an NSWindow as a sheet. The NSWindow has various controls for settings properties of an object (an NSTextfield, a NSDatepicker etc) and two NSButton's, 'Add' and 'Cancel' which are used to confirm or cancel the action. I have set the key equivalent of the 'Add' button to enter and the key equivalent of Cancel to escape. ...

How do you handle Domain Objects in an iPhone application?

I've got a few apps under my belt now, but I'm still relatively new to this. I'm looking for best practices advice or even a feature of the Cocoa Touch framework that I wasn't aware of, if anybody knows it. In the 1st app, I created Domain Objects in my Application Delegate, then would pass them off to my ViewControllers as needed. Fo...

Escaped unicode to unicode character in Cocoa

I get from a NSURLConnection a NSData object which I convert with [[NSMutableString alloc] initWithData:[self urlData] encoding:NSUTF8StringEncoding] to a NSMutableString. After some "revision" I display it in a NSTextField. But when the response contains a more-than-utf8-string this is displayed: This "&#x27A1" should be one unico...

How do I localize multiple files at once in Xcode?

In the process of localizing my app, I have about 50 resources (mostly xibs) that need to be localized. I know how to add a localization for each file, but it's a pretty time consuming process to open the info panel and add the localization for each file. Is there any way to select multiple files and add a localization to each of them i...

How to convert CFStringRef to NSString?

NSString *aNSString; CFStringRef aCFString; aCFString = CFStringCreateWithCString(NULL, [aNSString UTF8String], NSUTF8StringEncoding); aCFString = CFXMLCreateStringByUnescapingEntities(NULL, aCFString, NULL); How can I get a new NSString from aCFString? ...

NIB/XIB files with Cocoa programming - faster development time?

Hi, I have been programming with the iPhone SDK for some time now. I have not been using Interface Builder. This scares me a little. I know that in effect I may be 'fighting the framework' but I do not see it that way. I find it very easy to just instantiate my UITabBarController in my app delegate, instantiate a UINavigationControl...

terminating a secondary thread from the main thread (cocoa)

Hello I'm working on a small app written in objective-c with the help of the cocoa framework and I am having a multithreading issue. I would really appreciate it if somebody could help me with some guidance on how terminate a secondary(worker) thread from the main thread? - (IBAction)startWorking:(id)sender { [NSThread detachNewTh...