objective-c

Cocoa: Can I purposely block in a loop to wait for an asynchronous callback to finish?

Apologies in advanced for my confusion. I'm trying to do a batch upload of photos in my iPhone application. I have one script that's looping through a user's photos, and then for each photo, calls another script to do the upload. The script that does the upload needs to call back the script that's firing off each of the user's photos to...

ObjC/Cocoa class for converting size to human-readable string?

Is there a simple way to do something like.. [NSMagicDataConverter humanStringWithBytes:20000000] ..which would return "19.1MB"? ...

Memory management. Copy method

I use this code to copy and instance of my class //Create the copy and pass it onto edit controller PoolFacility *poolCopy = [self.thePoolFacility copy]; self.childController.thePoolFacilityCopy = poolCopy; [poolCopy release]; Now when I view the variables in the debugger, how come some of the class' fields have the same memory addres...

Truly modal UIAlertView in iPhone?

I'm need run a couple of validatins that depend on the decisions of the user (for example, if aprove a purchase above the spending limit), and deny the "done" action if it's fail. However, look like is not possible have a truly modal action like with other languajes (like showmessage, alert(), etc) and everything is by delegates. But t...

A shot in the dark - Application bug

Ok so this is gonna be a bit of a shot in the dark without you being able to see my application! I have a bug. I have a SwimmingPool class, my app passes the pool from a tableview into a detail view where you can see all the swimmingPool class fields. You can then click on the individual detail, edit it, and then save it. The 'original'...

iPhone SDK: what is the difference between loadView and viewDidLoad?

When working with views and view controllers in an iPhone app, can anyone explain the difference between loadView and viewDidLoad? My personal context, is that I build all my views from code, I do not and will not use Interface Builder, should that make any difference. I've found that often when I add init code to loadView, I end up ...

The iPhone and a PC?

Is it possible to create iPhone apps using a PC? I'm running windows vista and I want to learn objective-c, what better way can you be motivated then the potential to create something that someone, somewhere might use. Edit: Are there any hacks that allow would allow me to make the apps? ...

Displaying UITableViewCell's side by side, on the same row (As in Contacts -> Info)

If one navigates to the iPhone's Phone app, then goes to Contacts -> Info (on any contact).. you will see at the bottom of the contact there are two adjacent UITableViewCells, on the same row. In this particular case, they are "Text Message" and "Add to Favorites" How is this layout achieved? If there's any examples out there, that woul...

Cocoa strategy for pointer/memory management

I see a lot of code, particularly in Apple example code, that resembles the following: EditingViewController *controller = [[EditingViewController alloc] initWithNibName:@"EditingView" bundle:nil]; self.editingViewController = controller; [controller release]; Is there any reason in particular that the approach above proves...

Objective-C: How do I make a class with a 2d C array as a field?

Whenever I call the doSomething function my program crashes. The actual code as a bit of array bounds checking, so I know that's not an issue. myClass.h #import <Foundation/Foundation.h> @interface myClass : NSObject { BOOL **myMatrix; } @property(readwrite) BOOL **myMatrix; -(myClass*)initWithWidth: (int)w andHeight: (int)h; -...

Can you set code regions in Xcode?

When writing c#, in Visual Studio, you can set regions to group code accordingly. Being new to Xcode I can't seem to find a similar feature. ...

How to build a NSArray (or NSMutableArray) of class methods in Objective-C?

I'm trying to build a NSArray of methods in Objective-C. (What I'm trying to accomplish here is something like the following in C) typedef (void)(*handler)(int command); void handleCommandA(void) { ... } void handleCommandB(void) { ... } static const handler handler_table[10] = { handleCommandA, handleCommandB, handleCommandC }; ...

Objective-C use of #import and inheritance

I have a hypothetical UIViewController class named "foo". foo inherits from class bar and class bar #import's "Class A", a class which foo uses extensively. The problem is, when I'm using an instance of class A in foo, I don't get any compiler errors, but I do get a warning for instance, that an instance of Class A does not respond to a ...

Use of @synthesize/@property in Objective-C inheritance

If you have Class A with an instance var "foo" which has a @property/@synthesize directive, and Class B inherits from Class A, does it also need to @property/@synthesize "foo"? The reason I ask is because when I try to use Class B's "foo", the calling class says that "foo" is not something of a structured union or a member, which makes m...

My iphone application crashes

I made an application that should run constant until I stop it. What it basically does is getting some data from connected another device and send that data to the server periodically using NSURLConnection, and read data from the server periodically and visualize that data as a graph using NSXMLParser. I ran the instrument to check all...

iPhone Bug App bug Question and challenge..

Ok so I've got a really annoying bug in my app. It's driving me crazy and I'm sure it's beyond my skill level as I am learning as I go. Here is the initial rundown of the bug: http://stackoverflow.com/questions/573837/a-shot-in-the-dark-application-bug However I have found a way to consistently reproduce the bug (only on the device not...

iPhone: Flashing Colours

I am trying to get the iPhone background Color to change color every X number of seconds. How can I do this? I've been trying a UIAnimation but can only get it to change to the very last color in a list. Thanks alot! ...

Set default values for a global variable in a custom class?

I have a custom class that has quite a few accessor methods for customizing it. My question is, if a programmer uses this class and doesn't bother to assign values for ALL of these methods because he doesn't know about them or doesn't want to bother, how can I make the class assume a default view? I can't use awakeFromNib, because that w...

Binding two different model-key-paths to the same NSArrayController selection

Say I have the following array of dictionaries: { { isoName => en, fullName => English, localName => English }, { isoName => de, fullName => German, localName => Deutsch }, { isoName => fr, fullName => French, localName => français } } How ...

What's the best layout for a scrollable iPhone "detail view" with variable content?

I'm building a navigation controller based iPhone application and am curious how to go about building the detail view for my application. The part that's complicating my endeavor is: What UI elements/hierarchy should I employ to create a variable-height yet scrollable detail view? A great example of my goal is an arrangement like the m...