cocoa-touch

iPhone: helpfulness of didReceiveMemoryWarning:

I'm at the part of my development process for tracking down crashing and memory leaks. As a strategy, do you put any NSLog messages or notifications of some such into didReceiveMemoryWarning: ? The documentation for this method is rather sparse. Is it accurate to say that before a crash will happen, the UIViewController will trigger that...

iPhone CoreLocation: How to get the most accurate speed

I'm experimenting with adding the GPS functionality to my iPhone app. It's a workout app that will be used while walking or running. So what I want to use GPS for is to show the speed that the person is moving in Mph and minute/mile. How should I configure the CLLocationManager so I get the best possible results? What should I set desir...

What kind of odd behavior can occur during a memory leak on the iPhone?

Hi all, I've been able to replicate a bug consistently on an iPhone app I'm working on. The bug always follows as soon as my UIViewController's didReceiveMemoryWarning method gets invoked. Some of the issues I'm seeing are as follows: UITextField's text property niling out. The previous data in the UITextField is getting appended to...

drawRect question

When I call setNeedsDisplayInRect on a UIView, and the drawRect method fires...am I responsible for making sure I'm not rendering stuff that's outside the CGRect I called, or will the framework handle that for me? Example: -(void)drawRect:(CGRect)rect { //assume this is called through someMethod below CGContextRef ctx = UIGraphicsGe...

Dynamically Add values to UIPickerView at run time

How can you dynamically add values to UIPickerView at runtime. I'm using the following code to populate a UIPickerView statically. Need to add values dynamically at run time, for e.g. Three, Four etc. - (NSString *) pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ NSString *title ...

Fast drawing in large-sized custom view

I'm developing Piano App for iPhone. I'd like to develop smooth-scrollable keyboard (like Music Sampler). I put a custom view(1440px x 120px) in UIScrollView. I wanted to use OpenGL because Quartz is too slow. But I couldn't make OpenGL view in 1440px. Any idea to make a faster & large-sized custom view? Thank you. ...

Objective-C: finding who has a retain count to an object

I have a UIViewController which has a retainCount of 3 the moment I instantiate it. That stirs me as terribly incorrect. What's the best way of figuring out who bumped up the retainCount to 3? I'd imagine instantiating the object should give the pointer 1, then I suppose maybe pushing it onto the UINavigationController's stack might bump...

Instruments: checking for memory leaks inquiry

Hi all, I was curious, when one goes ahead and executes their code for leaks checking with Instruments -- is it prudent to hit all of the parts of the app manually to ensure memory leaks are occurring in that respective area? For instance, I believe I have some memory leaks in my application, deep within a UINavigationController tree. D...

iPhone question regarding memory management

Here's a hypothetical getter: - (DetailViewController *)detailController { if (detailController == nil) { DetailViewController *controller = [[DetailViewController alloc] initWithNibName:@"Detail" bundle:nil]; self.detailController = controller; [controller release]; } return detailController; } Then the ...

Do I release this instance variable on the iPhone?

I have a class which is responsible and the owner of building my model objects. It allocates memory for the models and has them retained and is responsible for releasing them when dealloc happens. Now I have a respective UIViewController which is acting as the client in this case. It will have several instance variables, pointing to the...

NSString @property, using copy instead of retain

I'm looking over Apple's sample application EditableDetailView, and noticed that in one of their controllers, they're setting an instance of NSString property with (nonatomic, copy). When would one use copy instead of retain? Is this so they can make a unique copy without affecting the existing data? ...

Possible for Instruments to show Leaks on autoreleased objects?

I'm having a difficult time understanding where actual Leaks are happening and where they are not in my application using Instruments. I have objects which are autoreleased and not being retained afterwards.. that are showing up as leaks via Instruments. There's also a bunch of objects which are listed as leaking that don't point back to...

NSMutableString and nil for memory management

If I have an NSMutableString such as NSMutableString *foo = [[NSMutableString alloc] init]; if I nil out the object, foo = nil, does that lower the retain count by 1, thus effectively releasing the memory? Would I need to reallocate foo from the heap at this point to be able to use it? ...

EXC_BAD_ACCESS error

I made an application that should run constant until I stop it. What it basically does is getting some data from connected another device and send that data to the server periodically using NSURLConnection, and read data from the server periodically and visualize that data as a graph using NSXMLParser. I ran the instrument to check allo...

how to increase font size in UIWebView

hi any one say , how to increase or decrease the UIWebview font size, not using scalePageToFit:NO; ...

Programming with Interface Builder in Landscape mode

Hi I want to design an application by using Interface Builder, in Landscape mode. I don't know how to put the controls suitable to the Landscape mode. All I know I m rotating my UIView by using self.transform. I am new in it. So can anyone help me. ...

Best way to store a large array of boolean variables?

i am working on a code which requires me to store 60*4 boolean values, the titles for these values are being stored in a plist. i require to manipulate the boolean values runtime and couldnt find a way to update the plist file easily..also using sqlite database for storing the boolean values becomes hectic for such large amount of data.....

How can I implement 2d Image animation on the iPhone?

I have a collection of various UIImage sequences I want to animate. It turns out that using a timer and doing drawRect has some perf problems. My next step was to investigate using UIImageView but apparently that has a memory leak if you update the array of animationImages more than once. My next step was to look into using CALayer a...

Question regarding a memory leak (screen shot from Instruments included)

Hi all, I'm trying to weed my application out of memory leaks. The problem I'm facing is that Instruments is reporting leaks for objects which I have not explicitly allocated myself. Now, I do understand that these objects might be instantiated as a result of some other code I've written, but I cannot find my client-code anywhere in the...

What are the main differences between Cocoa and CocoaTouch?

I am currently learning objective-c and cocoa. Next, I want to stick up to iPhone programming. I'll get a book for that, of course. But I would like to know already now, which main differences are there between cocoa and cocoaTouch. ...