Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 925941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:36:05+00:00 2026-05-15T19:36:05+00:00

I have upgraded my XCode to versio 3.2.3 to support iOS4 on my iphone

  • 0

I have upgraded my XCode to versio 3.2.3 to support iOS4 on my iphone project. using the static analyser I checked for memory management problems.

In one of my routines I get the following problem:
I generate a user alert after adding an event to the calendar to give him a status.

This runs fine, but the memory analyser doesn’t like how I defined the alert.
I can’t see the coding problem, do you? (I indicated the memory analyser hints with “<<<<“)

- (IBAction) addToCalendar {
        ...
    UIAlertView  *tmpAlert  = [UIAlertView alloc];        <<<<Method returns an Objective-C object with a+1 retain count (owning reference)

    calData.startDate   = iVar.zeitVon;
    calData.endDate     = iEvent.zeitBis;
    calData.title       = iVar.title;
    calData.calendar    = myEventStore.defaultCalendarForNewEvents;

    if ([tmpEventStore saveEvent:tmpEvent span:EKSpanThisEvent error:&tmpSaveError]) {
        // Show a save success dialog
        [tmpAlert initWithTitle:@"Success"        <<<<Object released
                        message:@"entry saved" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    } else {
        // Show a save error dialog
        [tmpAlert initWithTitle:@"Error" 
                        message:@"entry not saved" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] ;
    }
    [tmpAlert show];                               <<<<Reference counted object is used after its released
    [tmpAlert release];
}

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:36:06+00:00Added an answer on May 15, 2026 at 7:36 pm

    You should never decouple alloc and init. init often changes the object behind the scenes! Try

    NSString* foo=[NSString alloc]; 
    NSLog(@"%p %@", foo, [foo class]);
    foo=[foo initWithString:@"bar"]; 
    NSLog(@"%p %@", foo, [foo class]);
    

    You’ll see something like

    2010-07-14 01:00:55.359 a.out[17862:903] 0x10010d080 NSPlaceholderString
    2010-07-14 01:00:55.363 a.out[17862:903] 0x100001070 NSCFString
    

    This shows that +[NSString alloc] doesn’t really allocate anything; rather, what does the job is initWithString itself. I don’t think UIAlertView does this, but you never know.

    To recap: never decouple alloc and init. I think the static analyzer just assumes that everyone use [[... alloc] init], so that it got confused by your code. The analyzer should have warned you not to decouple alloc and init.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have upgraded from XCODE 4 to 4.2 and now i have problems. The
I have just upgraded to Xcode 4.3.1 and SDK 5.1. My project uses storyboard
I recently upgraded xcode to 4.2.1 (with macOS 10.7.3). I have two iphone which
I am trying to learn iphone programming and I have just upgraded xcode to
I just upgraded my Xcode ide. I have 3 logins. In the logins I
Have upgraded to eclipse.indigo using a new installation. Added m2e. Maven shows up under
I have upgraded a SQL Server Express 2005 instance to Standard using the best
I have upgraded my grails app from 1.3.7 to 2.0.1. I had few static
I have a project which I have upgraded to .Net 4.0, but when I
I've recently upgraded my Xcode version and have been having huge trouble trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.