objective-c

Create an array of integers property in Objective C

I'm having troubles creating a property of an array of integers in Objective C. I'm not sure whether this is even possible to do in Obj-C so I'm hoping someone can help me in finding out either how to do it correctly or provide an alternative solution. myclass.h @interface myClass : NSObject { @private int doubleDigits[10]; } @proper...

XCode: Delete line hot-key

I'm looking for a way to map some hot-keys to "delete the line that my cursor is on" in Xcode. I found "delete to end of line" and "delete to beginning of line" in the text key bindings, but I am missing how to completely delete the line no matter what I have selected. TextMate has this functionality mapped to Ctrl+Shift+D and I'd like t...

How to use NSString drawInRect to centre text?

How can I draw a string centred within a rect? I've started off with: (an extract from the drawRect method of my custom view) NSString* theString = ... [theString drawInRect:theRect withAttributes:0]; [theString release]; Now I'm assuming I need to set up some attributes. I've had a look through Apple's Cocoa documentation, but it's ...

Checking For Internet Connectivity in Objective C

I've been working through the Stanford iPhone Coding course and currently hooking into the Twitter API. What I'd like to do is accurately handle two error conditions: One for when the username is invalid, and another for when the device is not currently connected to the internet. Unfortunately, as it stands, the best I can surmise is whe...

How would I make a draggable Menubar icon for Mac OS X

Hey everyone. I am in the process of writing a menubar icon for an app i'm developing. However the NSStatusBar class does not have a method which would make the icon draggable, via cmd+left mouse drag. How do you make your menubar icon draggable with Objective-C code? Thank you :) ...

How combine TabBar + Navigation with XCode

I'm triying to combine a TabBar + Navigation app. I have 5 tab bars, 4 are listing of stuff and drill down to details views. I try to follow this tutorial: http://www.iphonedevforums.com/forum/iphone-sdk-development/124-view-controller-problem.html But always get a blank view. This is what I do, with a clean project: I start with ...

IPhone app terminating due to uncaught exception

HI, I am developing a iphone app by using cocos2d. Its shown this msg. 2009-01-26 16:17:40.603 Find The Nuts[449:20b] *** -[NSCFArray onTimer:]: unrecognized selector sent to instance 0x59be030 2009-01-26 16:17:40.605 Find The Nuts[449:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFA...

How do I declare a debug only statement

In c# I can use the following code to have code which only executes during debug build, how can I do the same in xcode? if #DEBUG { // etc etc } ...

Best way to manage probably huge photo library with iPhone SDK

I'm developing a app with a list of products. I wanna let the user have 1 picture for each products. Now, the problem is what to do next. I think that the best way is that the photos get sync when the user connect to their computer & itunes, and acces them from the app (something like: /photos/catalog/ref1.jpg. The other option is put ...

Correct technique for writing reusable interface objects?

I'm looking for the correct way to write my own interface objects. Say, I want an image that can be double-tapped. @interface DoubleTapButtonView : UIView { UILabel *text; UIImage *button; UIImage *button_selected; BOOL selected; } // detect tapCount == 2 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; This work...

Get the title of the current active Window/Document in Mac OS X

Refering to a previously asked question, I would like to know how to get the title of the current active document. I tried the script mention in the answers to the question above. This works, but only gives me the name of the application. For example, I am writing this question: When I fire up the script it gives me the name of the appl...

How make scrolling function with Interface builder on the iPhone?

I wonder how is possible to make a view scroll, like in a table view. I have a form that have several fields on it. I don't wanna buil it as a traditional table that drill-down. Is not very large but because the main windows is a tab-bar I lack of a bit of vertical space. Also, when I try to fill a textfield get covered by the keywoard...

How can I test an NSString for being nil?

Can I simply use if(myString == nil) For some reason a string that I know is null, is failing this statement. ...

Storing my ObJ-C class online. (amazon web services?)

Okay this is a fairly broad question. This is my first App and I'm not sure the best way to go about this. The app is on the IPHONE. I have a 'Restaurant' class. The restaurant has many different attributes and opening times. I currently store a restaurant in an instance of nsdata (it complies to NSCoding) LOcal storage is easy and I j...

QuartzCore.framework problem

I am trying to use QuartzCore Framework but when adding this framework to my iPhone application, I am told that the files (e.g. CIColor.h and others) are missing but those missing files exist on my hard drive under /system/library/ In addition to the QuartzCore Frame work, I am using the following frameworks: cocos2d, cocoa.framework, o...

TextField with Keyboard in cocos2d !

hello, I am trying to develop a iphone app by using cocos2d. I create a alert view with a text field. when I touch the text field then comes the keyboard. But I want that when the alert is open, in the same time textfield will be selected and keyboard comes(without any touch). how can it posible ? sorry for my bad English. ...

OCMock: Make a stub do something

I'm getting used to OCMock. Coming from a Java/JMock background I'm now looking for the ability to say [[[myMock stub] returnValueFromCustomMethod] someMockedMethod]; where returnValueFromCustomMethod is defined in the test class. I was originally thinking something along the terms of [[[myMock stub] usingSelector:@selector(myMethod:)] s...

Why is my comparing if statement not working?

Why is the following code (in cocoa) not working? NSString *extension = [fileName pathExtension]; NSString *wantedExtension = @"mp3"; if(extension == wantedExtension){ //work } in Xcode this just runs without warnings or errors but doesn't do what I think it SHOULD do. ...

How get the list of controls on a view with iPhone SDK?

I wanna do something like the safari app when fill a form, so when the user see the keyboard do next and move to next control. Now, how I get the next text control? ...

How programatically move a UIScrollView to focus in a control above keyboard

I have 6 UITextFields on my UIScrollView. Now, I can scroll by user request. But when the keyboard appear, some textfields are hidden. That is not user-friendly. How scroll programatically the view so I get sure the keyboard not hide the textfield? ...