Tag: objective c

如何在Objective-C中使用自定义委托

我需要知道在Objective-C中委托方法的用法。 任何人都可以指出我的来源?

编译,构build或存档问题与Xcode 4(和依赖项)

这个问题在过去的几个星期里已经有所发展,以涵盖xcode4的更多一般性问题(以及旧版xcode的升级项目)。 但是,许多问题可以通过遵循相同的指令来解决。 如果您遇到以下任何问题,请尝试接受的答案中的方法: Xcode 4无法存档应用程序 Xcode 4创build一个不可用的存档 Xcode 4不会创build一个.ipa 由于预处理器错误,Xcode 4无法编译 Xcode 4无法find标题 Xcode 4的代码完成不起作用 项目依赖不会编译 添加依赖会导致上述任何问题 原来的问题 标题: Xcode 4中的“词法或预处理器问题文件未find” 我有一个在Xcode 4中的项目,将build立罚款,并在设备和模拟器上运行,但是当试图存档错误时,查找与静态库相关的头文件: In file included from /Volumes/Development/Path/LBProject/LBProject/LBProject-Prefix.pch:15: In file included from /Volumes/Development/Path/LBProject/LBFDefines.h:23: In file included from /Volumes/Development/Path/LBProject/Classes/LBProjectAppDelegate.h:11: In file included from /Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDirectoryManager.h:10: /Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDataModel.h:11:9: fatal error: 'Merchant.h' file not found [1] #import "Merchant.h" ^ 1 […]

如何使用VideoToolbox解压H.264videostream

我在计算如何使用Apple的硬件加速video框架来解压缩H.264videostream时遇到了很多麻烦。 几个星期后,我想出来,想分享一个广泛的例子,因为我找不到一个。 我的目标是在WWDC14会议513中介绍一个video工具箱的全面,有益的例子。 我的代码不能编译或运行,因为它需要与基本的H.264stream(如从文件读取的video或从网上stream传输的video)集成,需要根据具体情况进行调整。 我应该提到,除了我在学习Google的过程中学到的知识之外,我对video编解码的经验还很less。 我不知道所有的video格式,参数结构等细节,所以我只包括我认为你需要知道的东西。 我正在使用XCode 6.2并已部署到运行iOS 8.1和8.2的iOS设备。

目标C反思/反思

有没有一个内置的方法,函数,API,普遍接受的方式等来转储Objective C中的实例化对象的内容,特别是在Apple的Cocoa / Cocoa-Touch环境中? 我希望能够做到这样的事情 MyType *the_thing = [[MyType alloc] init]; NSString *the_dump = [the_thing dump]; //pseudo code NSLog("Dumped Contents: %@", the_dump); 并显示对象的实例variables名称和值,以及可在运行时调用的任何方法。 理想情况下,一个易于阅读的格式。 对于熟悉PHP的开发人员,我基本上是在寻找等价的reflection函数( var_dump() , get_class_methods() )和OO Reflection API。

如何更改导航栏上“后退”button的标题

目前左栏button的默认值是加载当前视图的标题,换句话说,当按下button(后退button)时显示的视图的标题。 我想将button上显示的文字更改为其他内容。 我试图把下面的代码行视图控制器的viewDidLoad方法,但它似乎并没有工作。 self.navigationItem.leftBarButtonItem.title = @"Log Out"; 我该怎么办? 谢谢。

Apple Mach-O Linker编译设备时出错

我刚刚升级到xcode 4.0,我不能再部署到iPhone,我得到一个苹果Mach-O链接器错误,但它仍然适用于模拟器。 Ld /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel normal armv7 cd /Users/yveswheeler/iParcel setenv IPHONEOS_DEPLOYMENT_TARGET 3.2 setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -F/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -filelist /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel.LinkFileList -dead_strip -all_load -ObjC -lxml2 -miphoneos-version-min=3.2 -framework UIKit -framework CoreGraphics -framework QuartzCore /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Core.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Network.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Style.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UI.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework AddressBook -lz.1.2.3 -framework Foundation -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -framework MessageUI -framework […]

NSDate得到年/月/日

如果没有其他信息,我怎么能得到一个NSDate对象的年/月/日? 我意识到我可以用类似这样的方式做到这一点: NSCalendar *cal = [[NSCalendar alloc] init]; NSDateComponents *components = [cal components:0 fromDate:date]; int year = [components year]; int month = [components month]; int day = [components day]; 但是对于像NSDate的年/月/日那样简单的事情来说,这似乎是一大麻烦。 有没有其他解决scheme?

Objective-C中的自动引用计数不会阻止或最小化什么样的泄漏?

在Mac和iOS平台上,内存泄漏通常是由未释放的指针引起的。 传统上,检查你的分配,复制和保留以确保每个都有相应的释放消息一直是非常重要的。 Xcode 4.2附带的工具链引入了最新版本的LLVM编译器的自动引用计数(ARC),通过让编译器为你编写内存pipe理你的东西,完全消除了这个问题。 这非常酷,它确实减less了大量不必要的,平凡的开发时间,并防止了大量的不小心的内存泄漏,这些泄漏很容易通过适当的保留/释放平衡来修复。 甚至当您为Mac和iOS应用程序启用ARC时,需要对autorelease池进行不同的pipe理(因为您不应再分配您自己的NSAutoreleasePool )。 但是还有什么其他的内存泄漏不能防止我仍然需要注意? 另外,Mac OS X和iOS上的ARC和Mac OS X上的垃圾收集有什么区别?

UIImageresize无法正常工作

所以我一直在试图弄清楚我现在做错了一段时间,而我无法弄清楚。 我试图完成的是这样的: 用UIImagePickerController拍照 把拍摄的照片剪下来,把它变成方形(类似于Instagram) 在UIButton显示该图像 出于某种原因,每次我拍照时,都会在UIButton内部扭曲,看起来好像裁剪不能正常工作。 这是我所做的。 在didFinishPickingMediaWithInfo方法中,我有以下代码: – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { //Copy the image to the userImage variable [picker dismissModalViewControllerAnimated:YES]; userImage = nil; //Rotate & resize image userImage = [self resizeAndRotatePhoto:(UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage]]; NSLog(@"Userimage size, width: %f , height: %f", userImage.size.width , userImage.size.height); //Update the image form field with the image and […]

将UIColor保存到NSUserDefaults并加载

将UIColor保存到NSUserDefaults然后将其恢复的最简单的方法是什么?