objective-c

iPhone game loop hybrid

I had an idea for an app that would require me to implement these little sprites that would require basic physics features like gravity, acceleration, etc... so naturally I looked into a game loop for the iPhone, there were plenty of threads on this, but what I am trying to understand is that I want to be able to create these sprites and...

when to use respondsToSelector in objective-c

- (void)someMethod { if ( [delegate respondsToSelector:@selector(operationShouldProceed)] ) { if ( [delegate operationShouldProceed] ) { // do something appropriate } } } http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithOb...

Is it safe to call dismissModalViewControllerAnimated within a modal view on iOS?

Is it safe to call dismissModalViewControllerAnimated within a modal view? or should it be called from the controller that initiated the modal view? If so how would I program that? ...

#if Check between iphone and ipad

Is there a build preprocessor I can use, like #if or #ifdef to check whether my current xcode project is being built for iphone or ipad? ...

set delegate in objective-c on iOS

- (id)initWithDelegate:(id)delegate { self = [super init]; if (self) { _delegate = delegate; } return self; } Is it generally recommended to pass in the delegate in the init method? what about in another method that will be called first? Also do I need to set _delegate to nil or release in the dealloc or v...

Is it wrong to call an "init" method multiple times

If I'm getting updates to data - i.e. let's say some new returned JSON for example - then what do people think is cleaner? a) Just release any old objects, then create new ones. or b) Have -(id)initWithJSON:json type initializers that can 'reset' the data contained within the object to use the new data that is passed in. The second c...

Whats the proper way to release a UIWebView?

I've been looking at many code samples on the internet. If I add an UIWebView from interface builder as an IBOutlet. Is it right that in the dealloc method of the controller, I need to do the following? [webView stopLoading]; webView.delegate = nil; [webView release]; and what about in the viewDidUnload method? ...

Byte Arrays as member variables in Objective-C: Why isn't the value sticking around?

I'm sure I've got a basic problem in my C knowledge. I have one variable defined in the @interface: uint * theBytes; and then I have a method for checking the values of that array. - (IBAction) checkNow { NSLog(@"now? %d %d %d", theBytes[0], theBytes[1], theBytes[2]); } - (void)viewDidLoad { [super viewDidLoad]; uint tryThis[3...

CoreData Relationships Lazy Load?

When I have a CoreData entity named, say, 'Book', which has a one-to-one relationship with another entity ('Bookmark') would I need to insert both an instance of 'Book' and an instance of 'Bookmark' into a managed object context, and manually assign the relationship? If I perform the following code to instantiate an instance of 'Book'.....

Rotate MPMoviePlayerController to Landscape - iPhone SDK

Hello everyone, I am trying to rotate my MPMoviePlayerController to landscape view, but it always stays in portrait mode. I am doing this in a UIViewController and I still can't rotate my MPMoviePlayerController when I am in full screen mode. Do I have to do something to the shouldAutorotatetoOrientation method? If anyone knows how to d...

Create a copy of a NSObject

How do I take a NSObject that I have set all the attributes of and then copy that into another block of memory that an array can use so I can re use the original one? ...

error: nested functions are disabled, use -fnested-functions to re-enable

I'm getting error: nested functions are disabled, use -fnested-functions to re-enable. Could be a syntax. I just can't wrap my head around it. - (NSArray *)sortedVariants { NSInteger alphabeticSort(id object1, id object2, void *reverse) { if ((NSInteger *)reverse == NO) { return [[object1 name] localizedCaseInse...

Restart iPhone after installing or upgrading an app

What's the logic behind it? Ive been told by multiple apps to do this. I've also noticed that if I reinstall/build the app too many times from xcode, it will become unstable and more likely to crash. A restart does fix the problems. ...

How to append values to an array in Objective-C

Hi friends... I m doing this- for(int i=0;i>count;i++) { NSArray *temp=[[NSArray alloc]initWIthObjects]i,nil]; NSLog(@"%i",temp); } it returns me 0,1,2,3....count one by one. but i want array with appending these values {0,1,2,3,4,5...}. This is not a big deal but i m unable to find it....sorry...i am new to Iphone. ...

Ability to capture a video and uploading it into server in iphone sdk

Hi guy's As I am newbie to the Iphone Sdk I dont know how to Capture the video from our Iphone and upload the captured video to the Server. Guys please suggest me how to go through this with sample code. Thanks in advance, Monish. ...

Draggable objects in Cocoa

Hi all, I am completely new to objective c and have an quite ambitious project I want to create. One of the things I'll need to do is have a drawing layer, where I can have a circle in the middle, and be able to drag other circles near it to attach them, and then be able to move them around, changing their position around the initial c...

folder "__MACOSX " creating problem

Folder "__MACOSX" creating problem. I am doing something with my document directory folders , but there "__MACOSX" folder create problem . when user download application from app store . is it creating also in document directory ? if its creating then what is the solution to solve this ? please help. ...

How to convert data to JPEG format?

NSImage * strImage = [[NSImage alloc]initWithContentsOfFile:ImageFilePath] ; NSData *imageData = [strImage TIFFRepresentation]; now what I required is to convert imagedata into JPEG format. I want to work same as in QImage save() do. for the help how save() works i give you link below http://doc.qt.nokia.com/4.6/qimage.html#save pl...

how to recognize panning direction in UIImageView.

hi all, I am loading an image from server and displaying it in UIImageView.Now every time i pan the request is send to server which makes my application slow.Is there any way to find out in which direction the user is panning the image so that i can do the necessary... thanx in advance! ...

UIButton with NSInvocation

I am trying to add a button programatically in a way that upon pressing it, a certain object is being passed. I keep on getting "unrecognized selector sent" exception. Can you suggest whats wrong with the code: // allocate the details button's action SEL selector = @selector(showPropertyDetails:forProperty:); NSMethodSignatu...