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

  • Home
  • SEARCH
  • 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 6045077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:05:05+00:00 2026-05-23T07:05:05+00:00

I am a complete newcomer to Object C but I thought I had the

  • 0

I am a complete newcomer to Object C but I thought I had the idea of memory management at least fundamentally correct. I have this simple method:

-(int)weekIdFromDate:(NSDate *)inDate {

    NSCalendar *currentCal = [NSCalendar currentCalendar];
    NSDateComponents *component = [currentCal components:NSWeekCalendarUnit fromDate:inDate];
    int week = [component week];

    //I don't understand why this fails, it seems correct to release these objects now that they
    // are no longer needed
    [currentCal release];
    [component release];

    return week;
}

The method exists in my root view controller, but the warning is in the “main” function. I used a zombie to locate the cause of “BAD_ACCESS…”. All works fine with no issues if I comment these to releases out.

  • 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-23T07:05:05+00:00Added an answer on May 23, 2026 at 7:05 am

    You are releasing objects that you don’t own.

    The methods you use to get currentCal and component return autoreleased objects, which are not your responsibility to release.

    You only call release on objects that you get with new alloc or copy, or objects that you send a retain message. (Remember the mnemonic NARC).

    All explained in the Memory Management Guide

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

Sidebar

Related Questions

I'm a complete newcomer to this kind of thing, hence the simple question, but
complete HTML virgin 3 weeks ago but have managed to stumble along and get
Im complete noob to Javascript, but very keen to learn more. I have a
I'm a complete newcomer to Ruby on Rails so please forgive me if this
Complete C# newbie here, so cut me some slack. I have this application that
The complete warning is Validation (): Element 'html' occurs too few times This is
I have a complete XML document in a string and would like a Document
What is the complete and correct syntax for the SQL Case expression?
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
I'm a complete newcomer to xslt . I'm trying to come up with a

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.