objective-c

How do I make an allocator class method in Objective-C?

I have a class NSFoo that has a bar property. I want to have a class method to get an instance of NSFoo with the bar property set. This would be similar to the NSString stringWithFormat class method. So the signature would be: + (NSFoo *) fooWithBar:(NSString *)theBar; So I would call it like this: NSFoo *foo = [NSFoo fooWithBar: ...

Application Design Question: AppDelegate?

Hey friends, I am developing an iPhone app for some sweet undergrad research I've been working on. Sadly, my school doesn't offer software engineering / design classes so when it comes to questions of best practices in OO Design, I do a lot of reading. My Dilemma: My application loads a view (v1) where, upon user's button click, v1's ...

How would you make a checkbox delete a row in a table if checked (Cocoa) ?

My App Uses Coredata and Displays Data in a table, one column has a checkbox and one has the title. What i want it to do is that when the checkbox gets checked it deletes the row instead of people having using the Remove/Minus button. The reason I want this is because my app is a Task Management app. ...

Am I always responsible for didReceiveMemoryWarning being invoked by the iPhone OS?

Hi all, I have a quick inquiry regarding how and when didReceiveMemoryWarning gets invoked. I completely understand how to properly use the method. My question that I cannot find in documentation however, is whether or not it is my fault for the way I'm managing my memory footprint for this method being invoked? Is it possible that I'm...

access objective-c exception in finally block

Given the following situation: @try { @try { // raises an exception :) [receiver raisingFirstException]; } @finally { // raises another exception :) [otherReceiver raisingFinalException]; } } @catch (id e) { printf("exception: %s\n", [[e stringValue] cString]); } Is there any way to eith...

Has anyone implemented the PayPal API through a native iPhone app?

It seems the only way to stay "in app" is to give them a UIWebView of the paypal mobile site and let them complete the transaction there, otherwise the user would need to use their API key. Does this sound right and has anyone got or seen any sample code? I have to think this is a common piece of code. Thanks, Corey UPDATE: Will Appl...

What is the best Objective-C book for an experienced programmer?

What is the best Objective-C book for people who are already familiar with C, C++ and Java? It doesn't need to bother too much with basics, rather, focus on the language itself. Extra points if it focuses on explaining how Objective-C is different from other major OO languages. ...

Compiling an XML file into a binary

I want to parse and XML file in an iPhone app without going to disk for it. Can I do this? How? I have included a TXT helpfile in an app using MSVC. I put the XML file in a Folder/Group named Resources in the project. I have the XML file in the proj directory. I right clicked on Resources folder and selected add -> Existing File. I righ...

Multiple-line cursor movements in XCode

I'd like to map a key to move the cursor in the XCode up by ten lines. Of course, I want another one to move down too. The key mapping would ideally be something like 'Control-Alt-P'. Is there a way to achieve this in XCode without resorting to Automator? Ashley has the answer below, the formatting was a little different as the pro...

Disable undo for creation/deletion of NSManagedObject

In my Core Data model, I've got a relationship called listItems which links to several listItem entities, each with a stringValue attribute. I've created a control which is essentially a list of NSTextFields, one for each list item. The control is bound to listItems properly, and I've set it up so that pressing the return key creates a n...

UITableViewCell with image on the right?

Is there a way to set the UITableViewCell.image to display on the right hand side of the cell instead of the left? Or will I need to add a separate UIImageView on the right side of the cell layout? ...

How do I find all the property keys of a KVC compliant Objective-C object?

Hello, Is there a method that returns all the keys for an object conforming to the NSKeyValueCoding protocol? Something along the lines of [object getPropertyKeys] that would return an NSArray of NSString objects. It would work for any KVC-compliant object. Does such a method exist? I haven't found anything in searching the Apple docs ...

QTKit PAL Mode

I used MyRecorder sample by QTKit, it records everything but I have a problem that my camera is PAL and the resolution of H264 encoding for PAL and NTSC are different. PAL is 724x568 and NTSC is 724x480. When I choose QT Profile for H264High, it by default takes only 724x480 NTSC resolution output file but my camera is 724x568 so the fi...

How to signal an NSStreamEventEndEncountered on an NSInputStream reading from NSMutableData.

In Cocoa, I've setup two NSThreads, one producer and one consumer. The producer appends data to an NSMutableData, and the receiver opens an NSInputStream from that data and reads in chunks. The producer thread writes a lot faster than the consumer processes, which is OK. But the producer only produces a finite amount of work, then exits...

Objective-c: regular expressions

Hi, is there something similar to regular expressions for objective-c? I need a simple way to get elements from separated by following set of characters: "\n" ", " "; " Currently I have the following code: NSMutableArray *translations = [ [NSMutableArray alloc] init]; NSArray *temp_array1 = [ [translationsView text] componentsSepara...

Strip Carriage Return in iPhone

I parse an XML file with objective-c for Iphone. After parsing the result string variable got an enter character. How can strip it off from the string. Thank to everybody. ...

What's the best way of learning iPhone programming when coming from Java?

I've started to read all available apple docs on this topic. A fast overview gave me a number of about 8.000 (eight thousand) DIN A4 PDF pages. About 10% of the content is almost equal for my feeling. After reading for 2 weeks now, I figured out that I would forget fast what I have been reading a week ago. Unless I start to do something ...

String description of NSDate

Hi, I have the following code: [ [NSDate date] descriptionWithLocale: @"yyyy-MM-dd" ] I want it to return me date in the following format: "2009-04-23" But it returns me: Thursday, April 23, 2009 11:27:03 PM GMT+03:00 What am I doing wrong? Thank you in advance. ...

iPhone application is crashing and not leaving behind a .crash log file

Hi folks, I'm working on catching a seriously insidious bug that's happening in my code. The problem is, the bug is completely random and can happen either 9 minutes into the application's runtime or 30 minutes. I've gone ahead and added the fabulous PLCrashReporter to my project (http://code.google.com/p/plcrashreporter) and that works...

Soap xml for Paypal API SetMobileCheckout (rolling my own objective-c request)

I have the generic structure here: <?xml version=”1.0” encoding=”UTF-8”?> <SOAP-ENV:Envelope xmlns:xsi= ” http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” S...