【问题标题】:I get a "Incorrect decrement of the reference count of an object that is not owned at this point by the caller"我收到“调用者此时不拥有的对象的引用计数减少错误”
【发布时间】:2012-05-26 09:06:48
【问题描述】:

当我进行分析以找出潜在的内存泄漏时,我得到“调用者此时不拥有的对象的引用计数的错误递减”:

- (int)downloadUrlTofolder:(NSString *)url filename:(NSString *)name tryTime:(int)tryTime
{
    int result = 0;
     GetFtpService *ftpService = [[GetFtpService alloc] initwithUrlandOutPut:url output:name];

    //I have delete the code here, but problem is not solved.

    [ftpService release];  //the potential problem point to this line
    return result;
}

下面是“initwithUrlandOutPut”方法:

- (id)initwithUrlandOutPut:(NSString *)url output:(NSString *)o
{
    if(self = [super init]) {
        self.urlInput = url;
        self.outPath = o;
        self.success = [NSString stringWithString:@"success"];
        self.connected = nil;
    }

    return self;
}

还有界面:

@interface GetFtpService : NSObject <NSStreamDelegate>

@property (nonatomic, retain) NSInputStream *networkStream;
@property (nonatomic, copy) NSString *urlInput;
@property (nonatomic, retain) NSInputStream *fileStream;
@property (nonatomic, copy) NSString *outPath;
@property int tryTime;
@property (nonatomic, copy) NSString *success;
@property (nonatomic, copy) NSString *connected;

- (id) initwithUrlandOutPut:(NSString *)url output:(NSString *)o;

我想知道为什么会这样?以及如何解决?

【问题讨论】:

    标签: iphone objective-c memory-management memory-leaks


    【解决方案1】:

    我怀疑这是因为“initwith...”中的“w”没有大写。可能分析器因此没有将该方法识别为 init 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多