标签: automatic-ref-counting

Mixpanel iOS SDK和ARC

我正在尝试将Mixpanel SDK添加到使用ARC的iOS应用程序中.添加SDK后,我得到一些与ARC使用相关的编译错误.如何将Mixpanel集成到使用ARC的项目中?

在我的个人项目中,我总是手动管理mempory.也许有一些方法可以告诉编译器这段代码使用ARC而这段代码没有.

ios automatic-ref-counting mixpanel

0
推荐指数
1
解决办法
660
查看次数

在iOS 6 SDK中获取"observationInfo"会更改retainCount对象

我需要我的类的实例观察它自己的属性,所以我设置观察:

[self addObserver:self forKeyPath:@"myProperty" options:NSKeyValueObservingOptionNew context:nil]
Run Code Online (Sandbox Code Playgroud)

在dealloc中只需检查并删除观察者:

- (void)dealloc
{
    if ([self observationInfo])
    {
        [self removeObserver:self];
    }
}
Run Code Online (Sandbox Code Playgroud)

这个项目属于ARC,在iOS 6 SDK之前一切正常.但是使用iOS 6 SDK,observationInfodealloc使用EX_BAD_ACCESS(释放消息发送到解除分配的实例)之后,会增加对象和应用程序的retainCount 崩溃.

这段代码有什么问题?这是Apple的BUG还是我的?

更新 有栈跟踪:

thread #1: tid = 0x1f03, 0x016b60ab libobjc.A.dylib`objc_release + 27, stop reason = EXC_BAD_ACCESS (code=1, address=0xff000002)

frame #0: 0x016b60ab libobjc.A.dylib`objc_release + 27
frame #1: 0x016b6bd9 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 555
frame #2: 0x02538468 CoreFoundation`_CFAutoreleasePoolPop + 24
frame #3: 0x0253cafd CoreFoundation`__CFRunLoopRun + 1933
frame #4: 0x0253bf44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #5: 0x0253be1b …
Run Code Online (Sandbox Code Playgroud)

objective-c key-value-observing automatic-ref-counting ios6

0
推荐指数
1
解决办法
1815
查看次数

(目标C)从NSMutableArray获取CFstringRef

我有一个通过FTP下载的NSMutableArray.数组中的元素是CFSTPStream 资源常量,类型为CFStringRef.

我想从"kCFFTPResourceName"常量创建一个String.然而,作为Objective C和iphone开发的新手,我正在努力.

我所做的一切都导致ARC投掷适合或错误,如:

2013-01-03 15:31:44.874 Street Light Reporter[1382:11603] -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6e1e930
2013-01-03 15:31:44.875 Street Light Reporter[1382:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6e1e930'
Run Code Online (Sandbox Code Playgroud)

我最近的尝试是:CFStringRef*c = [ar objectAtIndex:4]; 哪个不起作用有以下两个原因:

Incompatible pointer types initializing 'CFStringRef *' (aka 'const struct __CFString **') with an expression of type 'id'
Run Code Online (Sandbox Code Playgroud)

Implicit conversion of an Objective-C pointer to 'CFStringRef *' (aka 'const struct __CFString **') is disallowed …
Run Code Online (Sandbox Code Playgroud)

iphone ftp xcode objective-c automatic-ref-counting

0
推荐指数
1
解决办法
865
查看次数

我如何证明ARC正在工作?

我有一个非ARC项目,我添加了一个新文件并为其设置了ARC编译器标志(-fobjc-arc).当我调用[object release]时; 在文件中,没有抛出编译器错误.我需要确定这个文件确实启用了ARC,我该如何证明?谢谢.

objective-c ios automatic-ref-counting

0
推荐指数
1
解决办法
123
查看次数

未保留UITapGesture目标(使用ARC)

我创建了一个UITapGesture,其目标不是当前对象.稍后,当点击时,应用程序崩溃.

查看控制器.h:

@interface ViewController : UIViewController
{
    IBOutlet UIImageView *iv;
}
@end
Run Code Online (Sandbox Code Playgroud)

查看控制器.c:

#import "ViewController.h"
#import "Target.h"

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    Target *t = [[Target alloc] init];
    UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:t action:@selector(gestureDone:)];
    [iv addGestureRecognizer:tgr];
    [iv setUserInteractionEnabled:YES];
}

@end
Run Code Online (Sandbox Code Playgroud)

Target.h:

@interface Target : NSObject

- (void)gestureDone:(UIGestureRecognizer *)gr;

@end
Run Code Online (Sandbox Code Playgroud)

Target.c:

@implementation Target

- (void)gestureDone:(UIGestureRecognizer *)gr
{
    NSLog(@"Gesture!");
}

@end
Run Code Online (Sandbox Code Playgroud)

(我的XIB文件只包含一个图像...)当点击图像时,它会崩溃.例如,如果我将一个实例变量Target*t添加到我的视图控制器(并在viewDidLoad中删除本地声明),则不会出现任何问题.如果不这样做,我会在Target中覆盖dealloc,在那里放置一个NSLog,并且只要viewDidLoad完成执行就会看到,目标对象就是fred.

我做错了什么,还是有问题?(通常我不会遇到这个问题,因为我使用initWithTarget:self ...).

objective-c gesture ios automatic-ref-counting

0
推荐指数
1
解决办法
644
查看次数

ARC的警告?

我使用以下代码行..

    NSArray *emailArray = (__bridge NSArray *)ABMultiValueCopyArrayOfAllValues(emailProperty);
Run Code Online (Sandbox Code Playgroud)

我正在使用ARC,但现在分析它时,它给了我一个警告"对象emailArray的潜在泄漏"......

我怎么解决这个..?任何帮助表示赞赏.

iphone objective-c ios automatic-ref-counting

0
推荐指数
1
解决办法
94
查看次数

需要有关ARC概念的帮助

在ARC环境中,我MyClass *mcObj = [[MyClass alloc]init]使用它之后会有一个对象,如果我这样做,或者mcObj = nil;在使用它之后执行此操作.

此对象可以存在于任何范围内,例如全局viewcontroller或仅在方法内部,-(void)aMethod;请解释这两种情况.

objective-c ios automatic-ref-counting

0
推荐指数
1
解决办法
185
查看次数

ARC下的iOS 5和6免费malloc内存

如何在ARC下的Objective-C中释放动态分配的内存?

通过dynamically我的意思是内存分配与malloc一些伊娃.

dealloc并且viewDidUnload不再被召唤,至少我的测试.

那么什么时候不再需要视图控制器何时以及如何开始释放内存?

我所做的是创建Releasable一个名为(我从C#偷走的想法)的协议,它有单一的方法-(void) release.当不再需要对象时,某些外部代理将调用此方法.

memory malloc objective-c ios automatic-ref-counting

0
推荐指数
1
解决办法
1250
查看次数

自动引用计数不会释放calloc

in my application, for encoding the string i am using当我在配置文件中运行应用程序时,我正在使用ARC calloc`它在calloc中显示内存泄漏.

在此输入图像描述

是否ARC会释放calloc

如果不是,为什么它不释放以及如何释放calloc

谢谢,

iphone objective-c ipad ios automatic-ref-counting

0
推荐指数
1
解决办法
381
查看次数

cellForRowAtIndexPath中对象的潜在泄漏

我收到以下代码的上述违规行为:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"Cell";

    UITableViewCell *cell = [tableView   dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
    }



        cell.textLabel.text = [mapContacts objectAtIndex:indexPath.row];
    NSLog(@"%@",cell.textLabel.text);
    cell.detailTextLabel.text = [number objectAtIndex:indexPath.row];



        return cell;


}
Run Code Online (Sandbox Code Playgroud)

违规行为显示return cell;可以采取哪些措施来解决这个问题?请帮忙.我正在使用带有ARC的XCode 4.5.

objective-c ios automatic-ref-counting xcode4.5

0
推荐指数
1
解决办法
594
查看次数