Skip to content

Instantly share code, notes, and snippets.

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"];
#define SafeBlock(BlockName, ...) BlockName ? BlockName(__VA_ARGS__) : nil
#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
针对Xcode能自动探知重名的category方法的问题,暂时找到了一个办法。
在工程的环境变量中加上OBJC_PRINT_REPLACED_METHODS并且值为YES,那么Xcode会自动log出重名的category方法
[UIView transitionWithView:_animatedLabel
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
_animatedLabel.textColor = colorChanged?[UIColor greenColor]:[UIColor blackColor];
} completion:^(BOOL finished) {
}];
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);
if ([self respondsToSelector:@selector(setSeparatorInset:)]) {
self.separatorInset = UIEdgeInsetsZero;
}
if ([self respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
self.preservesSuperviewLayoutMargins = NO;
}
if ([self respondsToSelector:@selector(setLayoutMargins:)]) {
self.layoutMargins = UIEdgeInsetsZero;
}
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)];
$ class-dump -C Pods_ /Applications/Squire.app | grep -o "Pods_\w+"
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}")