Widgets Do I need to override dealloc here?
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 30, 2015, 12:57:22 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 18 - Copying Objects
| | | |-+ Do I need to override dealloc here?
Pages: [1] Go Down
Author Topic: Do I need to override dealloc here? (Read 851 times)
Full Member
Posts: 175


on: September 25, 2011, 03:30:14 PM

Hi Stephen,

Don't I need to override dealloc and release name in this short program

Code: (Objective-C)
#import <Foundation/Foundation.h>
@interface test: NSObject
    NSString *name;
@property (nonatomic, copy) NSString *name;


@implementation test

@synthesize name;


int main (int argc, const char * argv[])

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    test *myTest = [[test alloc] init];
    NSMutableString *myString = [NSMutableString stringWithString:@"hello"]; = myString;
    [myString appendString:@"goodbye"];
    NSLog(@"myString = %@",myString);
    NSLog(@"name = %@",[myTest name]);
    [myTest release];
    [pool drain];
    return 0;

Any help is appreciated
Hero Member
Posts: 3114

Reply #1 on: September 26, 2011, 08:22:42 AM

Yes, because you use the copy attribute on the property, you would normally want to override dealloc here to release name.

Pages: [1] Go Up
Jump to:

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 All rights reserved.