objective-c

Discussion on 'didReceiveData' method for HTTP Connection

I created an indenpendent class for HTTP connection. All the connection works fine. The problem is that I find method 'didReceiveData' will be called AFTER the method who call the connection. (method 'didReceiveData' will be called after IBAction 'accept') - (IBAction)accept:(id)sender { [self connect:url]; //labelStr = ReturnS...

Query regarding "CGImageCreateWithImageInRect"

Hi, im trying to cut a image and mask it....that im able to do successfully..but the program exits after few minutes with 101 status - (void) maskImage { if(scopeOn==1){ UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; cachedImage=[UIImage imageNamed:@"loop.png"]; c...

Question regarding updating a UITableViewCell on the iPhone

I'm looking to do something simple such as drilling down on a particular UITableViewCell, which brings up a detail view controller. Within there, the user has the capability to change the attribute for the model underneath the cell. For instance, If I'm displaying a list of quotes, and a user clicks on a quote and favorites it in the chi...

Cocoa - Suggested techniques for debugging binding problems between XCode and Interface Builder

I am new to Cocoa and I am working my way through the examples in Hillegass's book 'Cocoa programming for Mac OS-X'. There have been a couple of occasions when a sample application I have been working through starts up and I get a message such as : 2009-03-11 00:39:19.167 CarLot[7517:10b] Cannot create NSData from object <_NSController...

Why do Objective C files use the .m extension?

Since I started learning Objective C and Cocoa, I've been wondering why did they choose the extension .m for the implementation files - was it supposed to mean something, or was it just a random letter? Does anyone know? I couldn't find such information anywhere on Google... ...

Using MD5 hash on a string in cocoa?

I need to hash a string using the MD5 technique in cocoa. Any frameworks that are used must be able to be accessed on the iphone. please provide code if possible. ...

What is the AppDelegate for and how do I know when to use it?

I'm just beginning to work on iPhone apps. How do I know when I should be putting stuff in the appdelegate versus a custom class? It there a rule or any type of analogy with another programming language like python or php that uses an appdelegate? Thanks... ...

Concatenating NSArray contents with NSMutableString AppendString

I'm trying to iterate through an NSArray and keep getting a compiler error right when i try concatenating the contents of my array at position i to my NSMutableString instance.. It just tells me that there's a "syntax error before ;" which doesn't tell me a whole lot. at this line: [output appendString:[widget.children objectAtIndex...

Is it possible to programmatically remove cookies for a domain in Cocoa/iPhone

Basically I make a request to a server using NSURLRequest, like: GET www.example.com/blah The response from the server tells the browser to set some cookies. I need these cookies to make subsequent requests to www.example.com/blah2 and blah3, etc. Once I have completed the series of sequential requests I need to rerun them, except I wa...

Finding a UIImage file type

Is there a way to determine what file type was used to create a UIImage? ...

How to Convert NSInteger to a binary (string) value

I am trying to figure out how to convert an NSInteger, say 56, to an NSString that is a binary representation of the original (int) value. Perhaps someone knows a formatting technique that can accept 56 and return "111000" within Objective C. Thanks All. ...

Not a number error (NAN) doing collision detection in an iphone app

I have a set of balloons that I am trying to get to bounce off of each other like balls. When I start to move them and then detect collision, the routine for the collisions eventually returns a NAN for the velocity of the balloons. I end up with a position of something like x=270, y= -nan(0x400000). I've been looking at the code all d...

How can I define an array in my Objective-C header file?

I have this code in my main file: int grid[] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 3 , 2 , 3 , 2 , 3 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 ...

How can I create a GUI and react to Cocoa events programatically?

I found out how to create a window in Cocoa programmatically but can't figure out how to react to events. The window is not reacting to a Quit request or button click. I tried adding the following controller and used setDelegate/setTarget without luck: @interface AppController : NSObject { } - (IBAction)doSomething:(id)send...

Normal Distribution function

edit So based on the answers so far (thanks for taking your time) I'm getting the sense that I'm probably NOT looking for a Normal Distribution function. Perhaps I'll try to re-describe what I'm looking to do. Lets say I have an object that returns a number of 0 to 10. And that number controls "speed". However instead of 10 being t...

NSNumber retain count issue

NSNumber* n = [[NSNumber alloc] initWithInt:100]; NSNumber* n1 = n; In the code above, why is the value of n's retainCount set to 2? In the second line of the code, I didn't use retain to increase the number of retainCount. I found a strange situation. actually the retainCount set to 2 is not related to the assignment of second line...

Modulo with long long integers in Objective C

I'm trying use the modulo operator (%) on long longs, and it seems to return 0 if the number is above the range of an unsigned int. Is there an operator or function that I should be using instead, or should I roll my own? -- Update: sorry for the lack of example code before, I was in a hurry, heading out the door -- Here's the code: l...

Is there an iPhone SDK API that I can use to get the current wallpaper image?

Is there an iPhone SDK API that I can use to get the current wallpaper image? I would like to use this image in a game. ...

Where should I store an image selected on the iPhone?

I want to take a picture or select an existing picture from the users existing photos. What is the best way to do this? Specifically I am concerned where I should to store the image. The storage location should be private to the application. I need to be able to reuse the image as a background every time the application opens. Thanks! ...

iPhone Out of Memory WEIRD crashing problem

Hi My app crashes after about 20 minutes with status 101 (Out of Memory, I believe) Debugging using Instruments - ObjectAlloc and Leaks gives me no clues. The ObjectAlloc graph stays at a nice constant level of around 1 million bytes (1MB), as does the Net # of allocations. I have got rid of all leaks. I thought it could be something ...