objective-c

Setter: [value copy] or [value release]?

I am a little curious about the last lines in the two examples presented below (i.e. planetName = [value ??????]) My understanding is that the 1st example with the copy is best as that takes a copy of the string object to protect against the original string object being changed elsewhere. I am also a little confused by the last line in ...

Hide API key from 3rd party?

The iPhone app that I am working on requires GET calls to a 3rd party site's api. The 3d part site does not offer SSL and requires the API key be in the GET request's querystring. What is the best way to secure this? I know I can have the iPhone app talk to my server and then my server send a request but I would like to avoid that if pos...

Differences in return object pointer?

Can someone explain the difference between these two, the first one is taken from allowing xcode to automatically generate the declaration, the last one is taken from an example in "Cocoa Programming" by Aaron Hillegass. - (NSString*)planetName { return [[planetName retain] autorelease]; } . - (NSString*)planetName { return p...

Setting property value of parent viewcontroller class from child viewcontroller?

Does anyone know how to update a property value from the subview (child) view controller? I have a int property called statusid defined with gettor/settor in parent view controller. [self.view addSubview:detailsVC.view]; In the child subview, I trying calling [super statusid:updatedValue]; to update statusid to a new value, but this cre...

Compare the value of a variable at intervals

Hey I have a problem comparing the value of a CGPoint (struct with two ints: x and y) with another at certain time intervals. One is called location and has the value of where the cursor is. Every half a second or so, I want to see if it changed. How do I do this? The language is Objective-C (so C++/C stuff should work) ...

How does Objective-C compare to C#?

I've recently purchased a Mac and use it primarily for C# development under VMWare Fusion. With all the nice Mac applications around I've started thinking about Xcode lurking just an install click away, and learning Objective-C. The syntax between the two languages looks very different, presumably because Objective-C has its origins in ...

Object not releasing objective C

I am having trouble understanding why NSLog reports "dog" when the code is run. I understand about retain counts and dealloc e.t.c. What simple thing am i missing ? NSString *newFoo = @"dog"; [newFoo release]; NSLog(newFoo); ...

EXEC_BAD_ACCESS when using NSOperation

This is pretty much the same problem i have, except with very different code: http://www.cocoabuilder.com/archive/message/cocoa/2009/3/24/233015 I want to offload some processing to an NSOperation, passing a filename as a reference that the NSOperation loads and parses. The app crashes with EXEC_BAD_ACCESS when entering -(void)init. He...

Fill a touch drawn path of CGPoints using OpenGL or CoreGraphics

I have a NSArray of points that make up a path. I can detect when it self-intersects. When this happens, I try to fill the path. First I used CoreGraphics, now I'm using openGl to draw a triangle array. Doesn't work well as you can see in the image. How do I fill only the circular area while leaving the "tail" alone? I was thinking of...

Disable iphone home button in app, is it possible?

hello, I want to develop a screensaver-like app where the only way of getting back to the springboard is entering a code. Therefore I would need the Home Button action to be ignored, that is that when the user presses the button nothing happens..or something custom...instead of going back to the springboard and terminating the app. Is th...

NSTableView responding to first click in a panel

I have noticed in the Interface Builder if I want to click on or drag from the Library panel, I only have to click on it once, even if the Library panel does not have the current focus. I am trying to build a panel that behaves similarly. Is there any simple way to let the NSTableView accept the click, even if the window does not have ...

Programatically switch tabs in iPhone

I have an iphone application which has about 4 tabs. How do I force the program to start on the second tab? Currently I have switched the first and second tab, but the aesthetics are horrid. ...

What is the start up/initialization procedure when an iPhone app is started ?

I would elaborate it as follows : In what order are the different objects and nib files instantiated/initialized ? My understanding is as follows: 1) UIMainApplication function loads the main .nib file specified in info.plist. 2) This .nib file instantiates the Delegate object. 3) When the appDidFinishLoading method runs, it generall...

refreshing mkannotation properties and refreshing the annotation.

Hi, I have a mkannotation located on a mapview which has a mkannotationview as well as a calloutview which when clicked goes to a child uiviewcontroller. I am updating some properties from the callout's uiviewcontroller, but after I'm finished I want to move the annotation's position on the map and change the annotation title and subti...

swipe to delete when already in edit mode

I have an iphone app using a uitableview where I'd like the "reorder" controls to always be displayed, and have the user swipe to delete rows. The approach I'm currently taking is to put the tableview in edit mode and allow selection in edit mode self.tableView.editing = YES; self.tableView.allowsSelectionDuringEditing = YES; I then ...

In Objective-C, how does +alloc know how much memory to allocate?

Let's say I have a class declared as: @class SomeClass @interface SomeClass: NSObject { NSString *myString; NSString *yourString; } @end And later, in some other code I say: SomeClass *myClass = [[SomeClass alloc] init]; How does SomeClass know how much memory to allocate given that it didn't override +alloc? Presumably it n...

Accessing data files in Objective-C or cocoa.

Hi Stackers! I am fairly new to a objective-c or in whole mac/iphone development. My question is how can I acces a data files(text files or flat files) in objective-c? For example I have a sample.txt file, how can I open this files and access its data? Do I need to use a class? And I heard about dictionary, is this term related to my pr...

"wait_fences: failed to receive reply: 10004003"?

I get this cryptic error the first time (and only the first time) my view is loaded due to the following line of code: - (void)viewWillAppear:(BOOL)animated { [textField becomeFirstResponder]; } There is a noticeable (~3 – 4 second, even on the simulator) delay due to this that makes my app feel unresponsive. Does anyone know how ...

Is there ever a need for a class to override +alloc in Objective-C?

Based on some answers to this question it appears that +alloc does some behind-the-scenes magic to allocate memory for an instance of an object in Objective-C. Is there ever a need to override +alloc? ...

"could not restore current frame" playing animation on iPhone

My application on iphone quit with following console message when we try to play the animation with 100 images again and again. Program received signal: “0”. warning: check_safe_call: could not restore current frame So i want to know how can i remove this crash. Am I doing anything wrong using animation? Code follows: catAnimationIma...