Skip to content

Instantly share code, notes, and snippets.

@sunnyxx
sunnyxx / attribute_overloadable_test.md
Last active July 18, 2018 04:59
__attribute__((overloadable)) test
__attribute__((overloadable)) NSString *descriptionFromValue(float value) {
    return @(value).stringValue;
}
__attribute__((overloadable)) NSString *descriptionFromValue(NSRange range) {
    return NSStringFromRange(range);
}
__attribute__((overloadable)) NSString *descriptionFromValue(id object) {
    return [object description];
}

解决多个 Xcode 导致的 N 个模拟器问题

效果(感谢汤哥的截图)

命令(来自百度知道唐代富):

  1. 彻底关闭 Xcode 和模拟器
  2. $ sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
  3. $ rm -rf ~/Library/Developer/CoreSimulator/Devices
@sunnyxx
sunnyxx / block with NS_REPLACES_RECEIVER
Created January 13, 2015 10:46
objc runtime block implementation with NS_REPLACES_RECEIVER
// Problem:
// I want to hack -awakeAfterUsingCoder: which has an attribute "NS_REPLACES_RECEIVER"
// Now I have a block version implmentation and to be added into UIView class
// It works fine in ARC with right object ownership
// But Xcode gives me a warning "ns_consumes_self attribute only applies to methods"
id (^newIMPBlock)(id, NSCoder *) NS_REPLACES_RECEIVER =
^id (UIView *self, __unused NSCoder *decoder) NS_REPLACES_RECEIVER {
// Do my staff
};
- (void)set_:(NSInteger)_
{
__ = _;
}