This file contains hidden or 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
NSString *imageName = nil; | |
CGSize screenSize = [[UIScreen mainScreen] bounds].size; | |
NSString *orientation = @"Portrait";//Landscape | |
NSDictionary *bundleInfoDict = [[NSBundle mainBundle] infoDictionary]; | |
NSArray *imagesDict = [bundleInfoDict valueForKey:@"UILaunchImages"]; | |
for (NSDictionary *dic in imagesDict) { | |
CGSize imageSize = CGSizeFromString(dic[@"UILaunchImageSize"]); | |
if (CGSizeEqualToSize(imageSize, screenSize) && | |
[orientation isEqualToString:dic[@"UILaunchImageOrientation"]]) { | |
imageName = dic[@"UILaunchImageName"]; |
This file contains hidden or 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
#define SafeBlock(BlockName, ...) BlockName ? BlockName(__VA_ARGS__) : nil |
This file contains hidden or 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
#if __has_feature(nullability) | |
# define __ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN | |
# define __ASSUME_NONNULL_END NS_ASSUME_NONNULL_END | |
# define __NULLABLE __nullable | |
#else | |
# define __ASSUME_NONNULL_BEGIN | |
# define __ASSUME_NONNULL_END | |
# define __NULLABLE | |
#endif |
This file contains hidden or 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
针对Xcode能自动探知重名的category方法的问题,暂时找到了一个办法。 | |
在工程的环境变量中加上OBJC_PRINT_REPLACED_METHODS并且值为YES,那么Xcode会自动log出重名的category方法 |
This file contains hidden or 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
[UIView transitionWithView:_animatedLabel | |
duration:0.5 | |
options:UIViewAnimationOptionTransitionCrossDissolve | |
animations:^{ | |
_animatedLabel.textColor = colorChanged?[UIColor greenColor]:[UIColor blackColor]; | |
} completion:^(BOOL finished) { | |
}]; |
This file contains hidden or 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
You want to use %zd for signed, %tu for unsigned, and %tx for hex. | |
NSInteger integer = 1;NSLog(@"first number: %zd", integer); | |
NSUInteger uinteger = 1;NSLog(@"second number: %tu", uinteger); |
This file contains hidden or 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
if ([self respondsToSelector:@selector(setSeparatorInset:)]) { | |
self.separatorInset = UIEdgeInsetsZero; | |
} | |
if ([self respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) { | |
self.preservesSuperviewLayoutMargins = NO; | |
} | |
if ([self respondsToSelector:@selector(setLayoutMargins:)]) { | |
self.layoutMargins = UIEdgeInsetsZero; | |
} |
This file contains hidden or 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
Mac OS: | |
[someNSView setSubviews:[NSArray array]]; | |
For UIView (iOS development only), you can safely use makeObjectsPerformSelector: | |
because the subviews property will return a copy of the array of subviews: | |
iOS: | |
[[someUIView subviews] | |
makeObjectsPerformSelector:@selector(removeFromSuperview)]; | |
This file contains hidden or 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
$ class-dump -C Pods_ /Applications/Squire.app | grep -o "Pods_\w+" |
This file contains hidden or 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
echo "Current Build Configuration : ${CONFIGURATION}" | |
if [ "Release" != "${CONFIGURATION}" ]; then | |
PATH=${PATH}:/usr/local/bin | |
IFS=$'\n' | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}") |