Skip to content

Instantly share code, notes, and snippets.

View acalism's full-sized avatar
🏠
Working from home

Dawn Song acalism

🏠
Working from home
  • Tencent, Alibaba
  • Shenzhen City, Guangdong Province, China
View GitHub Profile
@acalism
acalism / make-xcframework.sh
Last active May 26, 2022 02:51
best zshell script to create xcframework
#!/bin/zsh
# 必须用 zsh,否则后面的数组操作可能失败
# 需要编译的 scheme,可以改为你自己的,或者给脚本传递 -s 参数
scheme="T4"
configuration=Release
usesFramework=1 # 是否以 framework 为容器。framework 装的也可能是静态库
@acalism
acalism / AppleDevices.m
Last active October 31, 2022 06:05
How to get Device Model and Model Name(Human readable)
// see my comments
copy these files from Xcode 9 to Xcode 10 like this:
1. copy stdc++*.tbd to
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
2. copy stdc++*.dylib to
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
// same with each other
NS_AVAILABLE_IOS(10.0)
__IOS_AVAILABLE(10.0)
@acalism
acalism / confusing-naming-error.m
Last active August 12, 2018 02:41
ld error. It's really difficult to locate the problem.
// in header file
extern struct LALIMtopAPI {
__unsafe_unretained NSString *logout;
__unsafe_unretained NSString *login;
} const kLALIMtopAPI;
// implementation file
一、命名问题:
1. 想缩短类名或方法名时
2. 希望使用嵌套类
二、类型
1. 希望使用语法检查更严的泛型时
2. 想使用 String 枚举作为常量时
三、其他
1. 不希望在头文件和代码文件反复切换时
@acalism
acalism / objc-lightweight-generics.m
Created June 15, 2018 06:35
Implementation and Inheritance of objc lightweight generics
// Header File
NS_ASSUME_NONNULL_BEGIN
// No asterisk after DataType
@interface BaseCell<DataType> : UICollectionViewCell
- (DataType)data;
- (void)bindData:(DataType)data;
@acalism
acalism / objc-variable.m
Created June 14, 2018 02:41
Difference between ivar and global var
@implementation MyClass {
// It is an ivar, or called member variable
// Can NOT be initialized when defined.
// Can be accessed with `self->_i`
int _i;
}
int i = 9; // Global variable, and can be initialized when defined.
@end
#import <Masonry/Masonry.h>
@implementation ViewController {
UIView * _v;
UILabel * _label;
bool _constraintsAdded;
}
if #available(iOS 10.3, *) {
//SKStoreReviewController.requestReview()
//app.openURL(URL(string: "itms-apps://itunes.apple.com/app/id1018728680?action=write-review")!) // app前的cn段也不是必须啊
} else {
// Fallback on earlier versions
}