This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I have a URL and a UUID stored in UserDefaults, both as String. | |
* I want to extract both and convert the UUID string into an actual UUID. | |
* Here is something strange... | |
*/ | |
// This works on iOS. But on watchOS, the guard returns, even though the URL and UUID exist in UserDefaults | |
guard | |
let accountURL = UserDefaults.standard.string(forKey: UserDefaultKeys.accountURL.rawValue), | |
let accountUUIDString = UserDefaults.standard.string(forKey: UserDefaultKeys.accountUUID.rawValue), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// On iOS... | |
// This doesn't crash: | |
id null = @[[NSNull null]]; | |
dispatch_block_t block = (dispatch_block_t)null[0]; | |
block(); | |
// This does: | |
id null = [NSNull null]; | |
dispatch_block_t block = (dispatch_block_t)null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(lldb) p (int) [0x7d35ec40 hash] | |
(int) $14 = 16406 | |
(lldb) p (int) [0x79bef090 hash] | |
(int) $15 = 22 | |
(lldb) p (BOOL) [0x79bef090 isEqual:0x7d35ec40] | |
(BOOL) $16 = YES | |
(lldb) p (BOOL) [0x7d35ec40 isEqual:0x79bef090] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
typedef NS_ENUM(NSUInteger, MyEnum) { | |
MyEnumA = 1 << 0, | |
MyEnumB = 1 << 1, | |
MyEnumC = 1 << 2, | |
MyEnumD = 1 << 3, | |
MyEnumE = 1 << 4, | |
MyEnumF = 1 << 5, | |
MyEnumG = 1 << 6, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <objc/runtime.h> | |
@interface NSObject (MJGResponds) | |
+ (BOOL)mjg_hasImplementationForSelector:(SEL)selector searchUntilClass:(Class)cls; | |
@end | |
@implementation NSObject (MJGResponds) | |
+ (BOOL)mjg_hasImplementationForSelector:(SEL)selector searchUntilClass:(Class)cls { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SubclassNSObject : NSObject | |
@property (nonatomic, strong) SubclassNSObject *other; | |
@end | |
@implementation SubclassNSObject | |
@end | |
@interface SubclassUIViewController : UIViewController | |
@property (nonatomic, strong) SubclassUIViewController *other; | |
@end |