相关疑难解决方法(0)

静态库中的Objective-C类别

你能指导我如何正确地将静态库链接到iPhone项目.我使用添加到app项目的静态库项目作为直接依赖(目标 - >一般 - >直接依赖)并且所有工作正常,但是类别.静态库中定义的类别在app中不起作用.

所以我的问题是如何将静态库与一些类别添加到其他项目中?

一般来说,在其他项目的应用程序项目代码中使用的最佳做法是什么?

iphone objective-c static-libraries categories

148
推荐指数
5
解决办法
5万
查看次数

Objective C中的选择器

首先,我不确定我真的明白选择器是什么.根据我的理解,它是方法的名称,您可以将其分配给类型为"SEL"的类,然后运行诸如respondToSelector之类的方法来查看接收器是否实现了该方法.有人可以提供更好的解释吗?

其次,到目前为止,我有以下代码:

NSString *thing = @"Hello, this is Craig";

SEL sel = @selector(lowercaseString:);
NSString *lower = (([thing respondsToSelector:sel]) ? @"YES" : @"NO");
NSLog (@"Responds to lowercaseString: %@", lower);
if ([thing respondsToSelector:sel]) //(lower == @"YES")
    NSLog(@"lowercaseString is: %@", [thing lowercaseString]);
Run Code Online (Sandbox Code Playgroud)

但是,即使thing显然是一种NSString,并且应该响应lowercaseString,我也无法让'respondsToSelector'条件返回"YES"...

objective-c selector

121
推荐指数
4
解决办法
12万
查看次数

如何调试'无法识别的选择器发送到实例'错误

我正在为表视图创建自定义表格单元格视图.在我将自定义单元格(在故事板中)的图像视图连接到swift中的代码后,我收到以下错误.

[UITableViewCellContentView image]: unrecognized selector sent to instance 0x7fb4fad7fd20'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ccbb3f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010e7e9bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010ccc250d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010cc1a7fc ___forwarding___ + 988
    4   CoreFoundation                      0x000000010cc1a398 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010d7d8881 -[UITableViewCell _marginWidth] + 151
    6   UIKit                               0x000000010d7ca23d -[UITableViewCell _separatorFrame] + 70
    7   UIKit                               0x000000010d7ca6fa -[UITableViewCell _updateSeparatorContent] + 360
    8   UIKit                               0x000000010d7d4e85 -[UITableViewCell _setSectionLocation:animated:forceBackgroundSetup:] + 1174
    9   UIKit                               0x000000010d634ea8 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

98
推荐指数
4
解决办法
9万
查看次数