Hello again,

I have two basic Obj-C string question, please see the code below:

//.h file

@interface SomeClass : NSObject {

@private 
     NSMutableString *_someString;
}

@property (nonatomic, retain) NSMutableString *someString;

-(void)DoTheStringThing:(NSString *)aString;
@end

//.m file: 

#import "SomeClass.h"

@implementation SomeClass

@synthesize someString = _someString;

-(void)DoTheStringThing:(NSString *)aString {
     _someString = [[NSString alloc] initWithString:aString];
}

//in some other class...

-(void)foo {
     SomeClass *cls = [[SomeClass alloc] init];
     [cls DoTheStringThing:@"Here's a fun string."];

    //HERE IS THE QUESTION:
    //This causes a halt in the debugging and will sometimes give a 
_BAD_ADDRESS or something... simply checking the NSString pointer causes it
    //I am having a hard time I guess understanding Obj-C memory management b/c 
in traditional C/C++ this would be fine to do 
    if(cls.someString)
    {
          self.txtMyTextBox.text = [[NSString alloc] cls.someString];
    }
}

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

_________________________________________________________________
Get Windows Live and get whatever you need, wherever you are.  Start here.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home_082008_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to