Tag Archives: iphone

Xml serialization library for iPhone Apps [closed]

Questions: Apple provides the NSArchiver and NSUnachriver for object serialization / deserialization, but this can not handle any custom xml schema. So filling an object structure with the data of any custom xml schema has to be made manually. Since the iPhone developer community is rapidly growing, a lot of newbie programmer are despairing to… Read More »

Google Map Route Draw on IPhone

Questions: I am developing an application that has two versions. One for web and another for iPhone. In the web app, I am able to draw a route on the road (drawing the route automatically that follows roads/highways) and off road (draw direct line between two specific points). Is there an API, for iPhone, that… Read More »

Weak linking on iPhone refuses to work

Questions: I’ve got an iPhone app that’s mainly targetting 3.0, but which takes advantage of newer APIs when they’re available. Code goes something like this: if (UIApplicationDidEnterBackgroundNotification != NULL) { [nc addObserver: self selector: @selector(irrelevantCallbackName:) name: UIApplicationDidEnterBackgroundNotification object: nil]; } Now, according to everything Apple’s ever said, if the relevant APIs are weakly linked, that… Read More »

How use CGImageCreateWithImageInRect for iPhone 4 (HD)?

Questions: I use the following code to getting images from the sprite. And it works fine everywhere except the iPhone 4 (HD version). – (UIImage *)croppedImage:(CGRect)rect { CGImageRef image = CGImageCreateWithImageInRect([self CGImage], rect); UIImage *result = [UIImage imageWithCGImage:image]; CGImageRelease(image); return result; } The iPhone 4 automatically load HD version of the image (sprite@2x.png) instead sprite.png.… Read More »

How to draw a line with Cocos2d-iPhone

Questions: I’m trying to get to grips with Cocos2d by trying to accomplish simple things. At this point, I have a scene, that scene has a background sprite, and a Layer. I’m trying to draw onto the Layer using drawLine. Here’s my current attempt. @implementation MyLayer -(id)init{ self = [super init]; if(self != nil){ glColor4f(0.8,… Read More »

My button doesn't detect touch events on iPhone (Retina 4-inch) simulator, but works in iPhone (Retina 3.5-inch) simulator

Questions: I’m getting my app ready for the iPhone 5 using the simulator and I’ve found a weird issue where a couple of my buttons, in one of my views, don’t work in the iPhone (Retina 4-inch) simulator, but work fine in the iPhone (Retina 3.5-inch) simulator. The buttons simply don’t do anything when they’re… Read More »

Monitor memory usage in an iphone app?

Questions: Is it possible to monitor the amount of memory your app is consuming? Answers: Actually, it’s probably more important you know how much memory is free, rather than how much your app is using. Here’s some code to do that: #import <mach/mach.h> #import <mach/mach_host.h> +(natural_t) get_free_memory { mach_port_t host_port; mach_msg_type_number_t host_size; vm_size_t pagesize; host_port… Read More »

iPhone development: pointer being freed was not allocated

Questions: i got this message from the debugger: Pixture(1257,0xa0610500) malloc: *** error for object 0x21a8000: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug so i did a bit of tracing and got: (gdb) shell malloc_history 1257 0x21a8000 ALLOC 0x2196a00-0x21a89ff [size=73728]: thread_a0610500 |start | main | UIApplicationMain | GSEventRun |… Read More »