Tag: objective c

如何比较UIColors?

我想检查在UIImageView背景的颜色设置。 我试过了: if(myimage.backgroundColor == [UIColor greenColor]){ …} else{ …} 但即使我知道颜色是绿色的,它也不起作用,它总是落入其他部分。 另外,有没有办法在debugging控制台中输出当前的颜色。 p [myimage backgroundColor] 和 po [myimage backgroundColor] 不工作。

编译错误:“初始化元素不是编译时常量”

编译这段代码时,出现“初始化元素不是编译时常量”的错误。 谁能解释为什么? #import "PreferencesController.h" @implementation PreferencesController – (id)init { self = [super init]; if (self) { // Initialization code here. } return self; } NSImage* imageSegment = [[NSImage alloc] initWithContentsOfFile:@"/User/asd.jpg"];//error here

将input视图添加到文本框iOS 8时出错

当我在iOS 8上向自己的应用程序添加自定义input视图时遇到问题。这在iOS 7上工作得非常好,但切换到iOS 8时,一切都失败了。 这是堆栈跟踪: 2014-06-03 21:23:54.237 MyApp[1910:47245] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x1103f9d40> should have parent view controller:<StopChooser: 0x11083e200> but requested parent is:<UIInputWindowController: 0x110858800>' *** First throw call stack: ( 0 CoreFoundation 0x00000001042eee35 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000103b919a0 objc_exception_throw + 45 2 CoreFoundation 0x00000001042eed6d +[NSException raise:format:] […]

符号(S)未findbuild筑i386

当试图用Xcode进行编译时,出现以下错误: **Ld /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher normal i386 cd /Users/doronkatz/Sites/xCode/iKosher setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Xcode4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator -L/Users/doronkatz/Sites/xCode/iKosher -F/Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator -filelist /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Intermediates/iKosher.build/Debug-iphonesimulator/iKosher.build/Objects-normal/i386/iKosher.LinkFileList -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -lz -framework Security -framework CFNetwork -framework CoreData -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -o /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher Undefined symbols for architecture i386: "_UTTypeCreatePreferredIdentifierForTag", referenced from: […]

如何将NSData转换为iPhone中的字节数组?

我想将NSData转换为一个字节数组,所以我写了下面的代码: NSData *data = [NSData dataWithContentsOfFile:filePath]; int len = [data length]; Byte byteData[len]; byteData = [data bytes]; 但最后一行代码popup一个错误,说“赋值中的不兼容types”。 那么将数据转换为字节数组的正确方法是什么?

如何将对象添加到从Storyboard延伸到UIView之外的UIScrollView?

我想在我的应用程序中的长UIScrollView有几个button和其他对象。 在故事板中,我添加了一个UIScrollView来填充entre视图,然后在我的.h文件中创build一个IBOutlet 。 我在.m文件中合成了滚动条,然后使用下面的代码来启动滚动条: @synthesize scroller = _scroller; – (void)viewDidLoad { [super viewDidLoad]; [_scroller setScrollEnabled:YES]; [_scroller setContentSize:CGSizeMake(640, 3000)]; } 所以现在我需要知道如何实际添加诸如button之类的东西到视图中可以看到的下方的滚动区域。 我的问题是,因为我在故事板中添加了button,所以我只能在视图中添加东西,因此需要知道如何将button添加到将滚动到的部分! 希望这是明确的。 感谢你的帮助!

@符号在objective-c中代表什么?

我正在学Objective-C,并不断碰到@符号。 它用于不同的场景,例如在一个string的开始或合成访问器方法。 @符号在objective-c中是什么意思?

如何更新核心数据中的现有对象?

当我插入新的对象,我用下面的代码: NSManagedObjectContext *context = [appDelegate managedObjectContext]; Favorits *favorits = [NSEntityDescription insertNewObjectForEntityForName:@"Favorits" inManagedObjectContext:context]; favorits.title = @"Some title"; NSError *error; if (![context save:&error]) { NSLog(@"Whoops"); } 如何更新核心数据中的现有对象?

Swift编译器错误:“框架模块内部非模块化头”

现在我想将我的ObjC框架迁移到Swift,我得到了以下错误: include of non-modular header inside framework module 'SOGraphDB' 引用是一个头文件,它只是定义了一个协议,我在一些类中使用这个头文件来使用这个协议。 似乎与模块function有关,但目前尚不清楚如何解决,您是否知道解决scheme? 更新: 这是一个Swift编译器错误。 更新2: 快速修复(但不解决根本原因)是将以下设置设置为yes:CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES

Objective-C Cocoa应用程序中的正则expression式

初始Googlesearch表明在Objective-C Cocoa应用程序中没有内置的方法来执行正则expression式。 所以有四个问题: 这是真的吗? 你在跟我开玩笑吗? 好的,那么你有一个很好的开源库吗? 有什么办法可以在不导入图书馆的情况下使用NSScanner类来实现?