草庐IT

fno-objc-arc

全部标签

ios - 当使用 ARC 从 UIView 调用 dealloc 时,我可以假设仍然保留 ivars 吗?

我正在将UIView的子类上的KVO观察器添加到其subview之一。我也对subview有很强的引用。当我在dealloc的subview上调用removeObserver时,我可以假设subview仍然存在吗?我不想泄露观察者。基本上ARC中调用dealloc时,自动调用[superdealloc]是在调用之前还是之后? 最佳答案 来自http://clang.llvm.org/docs/AutomaticReferenceCounting.htmlAclassmayprovideamethoddefinitionforanin

ios - Venmo touch Braintree 支付 - 编译错误 : Undefined symbols for architecture i386: "_OBJC_CLASS_$_VTClient"

我已经使用cocoapod成功安装了braintreeiossdk,并且编译正常。但是,当我在我的appdelegate.m文件中初始化VTClient时。我遇到了编译错误:Undefinedsymbolsforarchitecturei386:"OBJCCLASS_$_VTClient",referencedfrom:objc-class-refinAppDelegate.old:symbol(s)notfoundforarchitecturei386clang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)而

ios - 为什么 ARC 在直接将对象分配给属性时无法正常工作

我有这两个对象//Headerfile#import@classObject2;@interfaceObject1:NSObject@propertyObject2*child;@end@interfaceObject2:NSObject@property(weak)Object1*parent;@end//ImplementationFile#import"MyClass.h"@implementationObject1-(void)dealloc{NSLog(@"deallocatingparent");}@end@implementationObject2-(void)deall

ios - 使用自定义 getter 和 setter 将消息发送到带有 ARC 的已释放实例

我正在尝试为我的自定义对象HFObject实现自定义getter和setter,尽管使用了ARC,但我的应用程序因Messagesenttodeallocatedinstance错误而崩溃。我已经阅读了每一篇相关的文章,那些在ARC之前写的不适用,其他的都没有帮助。我打开了僵尸对象调试器选项。设置自定义HObject在HObject.h中我声明了这四个属性:@property(retain)NSString*email;//Willusecustomgetter/setter@property(retain)NSString*firstName;//Willusecustomgette

ios - @try-@finally 用于保证在处理 ARC 未跟踪的对象时消除内存泄漏

假设我们使用malloc()/calloc()手动分配内存或分配一些ARC未跟踪的对象(如CGContextRef)。然后,我们正在做一些事情。最终,我们需要释放该内存。例子:void*buf=NULL;//malloc()allocatedobjectexampleCGContextRefcontext;//Non-manageablebyARCobjectexample@try{buf=malloc(bufSize);context=CGBitmapContextCreate(buf,width,height,bitsPerComponent,bytesPerRow,colorSp

objective-c - 如果我打开了 ARC,是否需要释放 SystemSoundID?

问题在标题中:“如果我打开了ARC,是否需要释放SystemSoundID?”这是我的代码:NSURL*pathURL=[NSURLfileURLWithPath:path];SystemSoundIDsoundid;AudioServicesCreateSystemSoundID((__bridge_retainedCFURLRef)pathURL,&soundid);AudioServicesPlaySystemSound(soundid);如果是这样,我什么时候发布它?(我没有dealloc方法,因为我使用的是静态方法并且无法更改)此外,这是目前播放音效的最佳方式吗?我听说这个框

ios - ARC 转换失败 : -ccc-arcmt-check argument "unused"

我正在尝试将我的iOS项目升级为使用ARC。当通过Edit->Refactor->ConverttoObjective-CARC开始转换时,我选择我的目标,取消选择链接库并按下检查。接下来我收到以下错误:clang:error:argumentunusedduringcompilation:'-ccc-arcmt-check'Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clangfailedwithexitcode1一些想法如何解决这个问题?X

ios - 使用 ARC 和 block 时保留循环

根据我的理解,当一个对象方法接收到一个block作为完成参数时,我可以在block中发送“self”:[objectdoMethodWithCompletion:^{[selfdoSomethingWhenThisMethodCompletes]}];但是如果这个对象“保留”了block(保存它以备将来使用)我应该发送一个我自己的“弱”副本:__weak__typeof__(self)weakSelf=self;object.savedBlock=^{[weakSelfdoSomethingWhenThisBlockIsCalledFromWithinObject];};但我也看到了变

ios - 在 ARC 中释放强引用

我的项目启用了ARC。我有一个类是NSObject的直接子类,我的类有一个NSArray(强引用)。我怎样才能释放我的阵列?我的理解InARCnoneedofreleasingobjectssetniltomyNSArray(Strongreference)indeallocmethodsetniltomyNSArray(Strongreference)inviewDidUnloadincaseofviewcontroller这是释放我的NSArray的正确方式吗?如果不是,那么正确的方法是什么? 最佳答案 所以首先,viewDid

ios - 错误 : Generic parameter 'R.Generator.Element' cannot be bound to non-@objc protocol type 'AnyObject'

我正在查询HealthKit并将其保存到CoreData。我在一个单独的类中获取数据。在TableViewController中,我将数据附加到数组:ifNSUserDefaults.standardUserDefaults().boolForKey("weightSwitch")==true{xAxisDatesArray.append(cdFetchWeight.queryCoreDataDate())yAxisValuesArray.append(cdFetchWeight.queryCoreDataData())并将其传递给tableView.dequeueReusableCe