Search Results

Search found 3 results on 1 pages for 'noblek'.

Page 1/1 | 1 

  • ObjectiveC - Releasing objects added as parameters

    - by NobleK
    Ok, here goes. Being a Java developer I'm still struggling with the memory management in ObjectiveC. I have all the basics covered, but once in a while I encounter a challenge. What I want to do is something which in Java would look like this: MyObject myObject = new MyObject(new MyParameterObject()); The constructor of MyObject class takes a parameter of type MyParameterObject which I initiate on-the-fly. In ObjectiveC I tried to do this using following code: MyObject *myObject = [[MyObject alloc] init:[[MyParameterObject alloc] init]]; However, running the Build and Analyze tool this gives me a "Potential leak of an object" warning for the MyParameter object which indeed occurs when I test it using Instruments. I do understand why this happens since I am taking ownership of the object with the alloc method and not relinquishing it, I just don't know the correct way of doing it. I tried using MyObject *myObject = [[MyObject alloc] init:[[[MyParameterObject alloc] init] autorelease]]; but then the Analyze tool told me that "Object sent -autorelease too many times". I could solve the issue by modifying the init method of MyParameterObject to say return [self autorelease]; in stead of just return self;. Analyze still warnes about a potential leak, but it doesn't actually occur. However I believe that this approach violates the convention for managing memory in ObjectiveC and I really want to do it the right way. Thanx in advance.

    Read the article

  • Disabling multitasking on iPhone 3GS using UIApplicationExitsOnSuspend not working

    - by NobleK
    Hello I am developing an iPhone app where I don’t want/need the multitasking capability and I want my app to initiate every time I open it. I have set the UIApplicationExitsOnSuspend property in the info.plist and it does work when I test it on my iPhone 4 and in the simulator (which is also an ”iPhone 4”). The app calls applicationDidEnterBackground followed by applicationWillTerminate. However, when testing it on my wifes iPhone 3GS the property seems to be completely ignored and the program gets suspended/resumed. Both phones are running iOS 4.2.1. Someone has also confirmed this issue in another thread, with no solutions unfortunately: iPhone: how to test if UIApplicationExitsOnSuspend is working? Is there something I am missing to make this work? Any other ways to accomplish this? Thanx in advance

    Read the article

  • How to check if location services are enabled for a particular app prior to iOS 4.2?

    - by NobleK
    Hello How can I check if the user has allowed location for mu app? Normally I would use authorizationStatus method of the CLLocationManager class, but it is only available in iOS 4.2 and newer. Is it possible to achieve this somehow while still using SDK 4.2, so that the app can still run on devices with older versions of iOS, or do I have to downgrade the SDK? And along the same line, I need a similar alternative for the locationServicesEnabled method prior to iOS 4.0. Thanx

    Read the article

1