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 8614399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:06:45+00:00 2026-06-12T05:06:45+00:00

In my class dealloc method I have – (void) dealloc { [searchField release]; [super

  • 0

In my class dealloc method I have

- (void) dealloc
{
    [searchField release]; 
    [super dealloc];
}

Where searchField is defined in the class variables.

@interface SearchCell : UITableViewCell
{
    UISearchBar *searchField;
    id delegate;
}

The class is used with the following way:

if (indexPath.section == 0)
    {
        SearchCell *mycell = [[SearchCell alloc] init];
        [cell setDelegate:self];
        return [mycell autorelease];
    }

searchField is created here:

- (id) init
{
    self = [super initWithFrame:CGRectZero];

    [self create];

    return self;
}

- (void) create
{
    searchField = [[UISearchBar alloc] initWithFrame:CGRectZero];
    searchField.autocorrectionType = UITextAutocorrectionTypeNo;    
    [self addSubview:searchField];
}

Do I need to use [searchField release]; in my dealloc? The application crashes with message: “*[UISearchBar respondsToSelector:]: message sent to deallocated instance *“.

  • 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-06-12T05:06:46+00:00Added an answer on June 12, 2026 at 5:06 am

    You need to be aware of object ownership rules. In manual retain & release environment (as opposed to ARC) the rules for Objective-C objects can be remembered with the acronym NARC.

    If you have a reference to an object that you created fresh using new or alloc, or any object that you called retain on, or any object you created by calling copy or mutableCopy on another, or any object created by any methods that start with any of these names (e.g. newInstance), then
    you own that object and before you are deallocated you must release it.

    But, if you didn’t do any of those things, then you do not own that object, and must not release it. source

    In your case – you don’t show the code where you set the value searchField, but from the crash I’d imagine you never take ownership of the object. Show the code where you assign to searchField and we’ll all know for sure.
    EDIT: You do take ownership by creating it with alloc. You need to keep the release there in dealloc. Is it being released from somewhere else? Or is the cell itself possibly getting overreleased?

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

Sidebar

Related Questions

Do I have to call release in the dealloc method of a class for
class a{ public void foo(int a){ System.out.println(super); } } class b extends a{ public
I have a very classical class which contains buttons and label, etc... : @interface
I have a static array in my class. When do i release it? or
If I have a class @interface Foo { NSString *temp; } @property(nonatomic, copy) NSString
I have a property with name bgImage in my custom UITableViewCell class (MyTableCell). Its
I have an Objective-C class that looks something like: @interface myClass : NSObject {
I have a class derived from NSThread : @interface FSEventMonitorThread : NSThread { FSEventStreamRef
I have a -dealloc() method which I am assuming I can use to dealloc
I am facing memory leak issue with very simple code.I have class 'TestClass' @interface

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.