Objective C alloc/release error

后端 未结 4 1854
庸人自扰
庸人自扰 2020-12-07 06:19

I have the following problem:

in header;

GDataXMLDocument *doc;
NSString *xmlBody;
@property (nonatomic,copy) NSString *xmlBody;
@property (nonatomic         


        
4条回答
  •  暖寄归人
    2020-12-07 06:51

    NSData *xmlData = doc.XMLData;
    newXML = [[NSString alloc] initWithBytes:[xmlData bytes] length:[xmlData length] 
    encoding:NSUTF8StringEncoding];
    

    What is your newXML? is it a ivar and synthesize it and retain it? if yes the compiler will automatically generate getter and setter methods.

    NSData *xmlData = doc.XMLData;
    self.newXML = [[NSString alloc] initWithBytes:[xmlData bytes] length:[xmlData length] 
    encoding:NSUTF8StringEncoding];
    self.timestamp = nil;
    

    If its not property then

    NSString* newXML = [[NSString alloc] initWithBytes:[xmlData bytes] length:[xmlData length] 
    encoding:NSUTF8StringEncoding];   
    self.xmlBody=newXML;   
    [newXML release]; 
    

提交回复
热议问题