objective-c

If a method is called at the exact same time twice, how to only execute it once?

We have a method in the iPhone SDK that is a delegate method. Problem is, the OS calls this method twice at the exact same time. This method does some heavy lifting so I don't want to execute the logic twice. What is a good way to detect this and prevent one of the two from running? Forgot to mention that, it is called from different ...

Sample code for creating a NSTextField "label"?

In my desktop Mac OS X app, I'd like to programatically create a NSTextField "label" which has the same behavior and properties as a typical label created in Interface Builder. I usually use (and very much like) IB, but in this case it must be done programatically. Try as I might, I can't seem to find the combination of method calls th...

How can I define my custom collate in Sqlite (in Objective-C) (for iPhone)

I need to define an arbitrary comparison method for sqlite in code. I need to be able to search for "e" and find both "e" and "é" (this is an example and the actual characters are in Persian). any help appreciated. ...

Releasing a CocosNode and adding its children to Layer in Cocos2d

I'm working on a Tetris clone in Cocos2d for the iPhone and I'm using a Block class of Sprites for the individual blocks and a Tetromino CocosNode class that the user controls in order to move the Blocks. All of these Blocks move around in a 20 by 10 grid of empty Blocks on the GameBoardLayer. When the block finishes falling, I'd like ...

Link with File's Owner problem

I created a nib file "WebViewController.xib". And try to link the UIView with File's Owner. But it doesn't work. Also sometimes with other nib files, I deleted a connection from View Connections->Referencing Outlet, then tried to connect again, but it can't link with File's Owner anymore. How to fix this? Thank you. ...

Aspect-Oriented Objective-C Library?

Is there any Aspect-Oriented Objective-C library that I could perhaps use for iPhone development? ...

App Crashes when NavigationController is popped!

Hi, Below is what I copy/pasted from the Crash Log sent by the client. I am unable to understand what does that mean :s Apparently it looks like the app crashed when navigating back to a previous screen (and that's what client has reported). What is UIWebDocumentView here? I need to resolve the crash but I'm stuck here so any help is h...

UILabel instead of the default pin on MKMapView

Is it possible to have our own UILabel or some other type of text instead of the default pin in MapKit map on iPhone? ...

iPhone keyboard-button style for any UIView / UIButton?

Hi guys, I have a custom keyboard in my app and I'd like to have it look similar to the original iPhone keyboard (especially the buttons), just like it has been realized in Twitterrific, for example. Can you point me to a resource where I could find such code, either as a custom drawRect method or as a TTStyle pipeline? Cheers MrMage ...

UIView with rounded corners

Basically i have a login View which has a subview and it has a UIActivityView and Label saying "Signing In....", this subview has a corners which are not "round", how i can make them to look like "rounded" Is there anyway to do it using IB? ...

Objective-C: elegant solution to conditional creation of objects?

Hello, This is an Objective-C/iphone SDK question. I have a dashboard view that is used to switch to different views in my application. Essentially the view has six buttons that shortcut to a different view. Here is an example of the button event handling code: - (IBAction)moreButtonPressed:(id)sender{ // switch view here if(self....

Clang: what is "Method returns an Objective-C object with a +0 retain count" trying to tell me?

Running a static analysis with clang in both XCode 3.2 and Nikita Zhuk's Analysis Tool I've often come across this pair of warnings: Method returns an Objective-C object with a +0 retain count (non-owning reference) Incorrect decrement of the reference count of an object is not owned at this point by the caller An example of c...

Is there a way for find how many keys are currently in a NSMutableDictionary?

Just curious if there is a way to find the number of keys in a NSMutableDictionary? Also is there a way to access each key in turn and find its value, or do I need to access the data manually via the predefined keys? (i.e.) myTown = [cryo objectForKey: @"town"]; myZip = [cryo objectForKey: @"HT6 4HT"]; myEmail = [cryo objectForKey: ...

Assigning different labels dynamically

Hi everybody! After detecting Button sender through its tag in an action method, I want to dynamically assign some text to the corresponding Label (say, button tag+10 ) using some sort of temp UILabel var. Hoping that's understandable?..english is not my native language :) thank you. ...

Help with Key-Value-Observing.

I need a bit of help with KVO, I'm about half way there. What I'm trying to do is trigger a method when something in an Tree Controller changes. So I 'm using this code to register as a KVO. [theObject addObserver: self forKeyPath: @"myKeyPath" options: NSKeyValueObservingOptionNew context: NUL...

Keep playing sound with MPMoviePlayerController and locked screen?

Hey, you know when youre wathing a video with MPMoviePlayerController and the user presses the top button to lock the screen, the app goes to sleep, and so does the sound of the video, is there any way to prevent the lock from stoping the sound? If not, is there a way to intercept the lock, to create a "custom lock", to save some battery...

Alternative for print_r in php for iphone(objective-c)?

Hi there :) I've started with objective-c/iphone programming a couple of days ago, and still having some problems converting from other languages.. I'm currently testing around with NSArrays, and NSMutableArrays, and it's really annoying that I haven't found any method for effectively displaying the contents of my arrays (without creati...

UIWebView does not scale content to fit

I have a webview which is the top window in the hierarchy and has been declared as shown below. However, it does not scale pages to fit. Pages are top left aligned, but are not scaled, despite the scalesPageToFit property being set to YES. Any help would be greatly appreciated. webLookupView = [[UIWebView alloc] initWithFrame:CGRectMake...

Count-Up Timer Required, iPhone Programming

Hi Guys, I am new to iPhone programming so am hoping someone can help me out here. I have searched the web, but can only find information on count down timers. What I am looking to do is start a count up timer when a button is pressed and then stop it when a certain value drops by, say 5, and finally display that time. I can display va...

Getting the chosen color from a color well programatically

I have built a color well using objective c and cocoa but I am having trouble getting the color out using takeColorFrom:. My example would not be useful because I am writing all this in lisp with an objective c bridge. Could someone link me to an example of how to do this in objective C and I can easily translate from that. ...