Skip to content

Instantly share code, notes, and snippets.

View monsoir's full-sized avatar

Monsoir monsoir

View GitHub Profile
#ifdef DEBUG
#define DLog(format, ...) NSLog(format, ## __VA_ARGS__)
#else
#define DLog(format, ...)
#endif
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"[文件名:%s]\n" "[函数名:%s]\n" "[行号:%d] \n" fmt), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...);
#endif
[UIColor colorWithRed:0 green:0 blue:25/255.0 alpha:44/255.0].CGColor
/*
1. When creating a date from a string using date formatter, hour format of NSDateFormatter.dateFormat should be 'h' or 'hh' in 12-hour, and 'H' or 'HH' in 24-hour.
2. When creating a date in 12-hour, the AM/PM format of NSDateFormatter.dateFormat should be 'a', just one 'a'.
3. NSDateFormatter, NSDateComponets, NSCalendar has a NSTimeZone property, which means their time a related a specific time zone. While NSDate does not a NSTimeZone property, which means its value is a absolute value calculating from 00:00:00 UTC on 1 January 2001
*/
- (UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
_tableView.estimatedRowHeight = 44.f;
_tableView.delegate = self;
_tableView.dataSource = self;
}
#pragma mark - Initializer
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setupSubviews];
}
return self;
}
self.searchBar.scopeBarBackgroundImage = [[UIImage alloc] init];
self.searchBar.backgroundImage = [[UIImage alloc] init];
NSString *inputLanguage = [[UIApplication sharedApplication] textInputMode].primaryLanguage;

Target -> Build Settings -> Packaging -> Product Name.

Sometimes, we will get this error:
> Error Domain=NSCocoaErrorDomain Code=3840 "Unable to convert data to string around character 28." UserInfo={NSDebugDescription=Unable to convert data to string around character 28.}
The reason that causes this error is that the encoding(GBK for example) of the response data is not compatible with the default encoding(UTF-8) of iOS.
To resolve this, we need to convert the encoding of response data to UTF-8.
Here is the inline method of converting the encoding to UTF-8:
```objc