Xcode代码片段共享 使用: git下载完,放在系统~/Library/Developer/Xcode/UserData/CodeSnippets
@property(nonatomic, assign) ____[var]____
@property(nonatomic, strong) ____[var]____
@property(nonatomic, weak) ____[var]____
id____[protocol]____ ____[delegate]____;
NSMutableArray *____[mutableArray]____ = [NSMutableArray array];
NSMutableDictionary *____[mutableDict]____ = [NSMutableDictionary dictionary];
- myAlertView ------>定义一个uialertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:____[@“title”]____ message:____[message]____ delegate:self cancelButtonTitle:@"取消" otherButtonTitles: @"确定",nil];
alert.delegate = ____[nil]____;
[alert show];
static NSString *cellIdentifier = ____[@"cellIdentifier"]____;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
int numberOfRows = 0;
____[code]____
return numberOfRows;
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
int numberOfSections = 1;
____[code]____
return numberOfSections;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
____[UITableViewCell]____ *cell = [tableView dequeueReusableCellWithIdentifier:____[@"cell"]____];
if (nil == cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:____[@"cell"]____];
}
____[code]____
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
float height = 0.0f;
____[code]____
return height;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
float height = 0.0f;
____[code]____
return height;
}
- (void)____[btn]____Clicked:(id)sender
{
}
-(void)dealloc
{
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
____[code]____
}
//add by ____[author]____, begin
//reason:____[reason]____
//date:____[yyyy]____-____[mm]____-____[dd]____
____[code]____
//add end
[[APMonitorPointManager sharedInstance] addLogsAndKeys:kActionID_____[key]____, kActionID,
____[业务ID]____, kBizID, ____[埋点ID]____, kActionSeed,
____[当前视图]____,kCurrentViewID, ____[上一个视图]____,kLastViewID,
____[(NSString *), ...]____, nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentDirectory = paths.firstObject;
if (____[condition]____)
{
____[code]____
}
else if (____[condition]____)
{
____[code]____
}
else
{
____[code]____
}
dispatch_async(dispatch_get_main_queue(), ^{
____[code]____
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
____[code]____
});
switch (____[expression]____)
{
case ____[constant]____:
{
____[code]____
break;
}
default:
{
____[code]____
break;
}
}
case ____[constant]____:
{
____[code]____
break;
}
@synchronized(self)
{
____[code]____
}
//test
#ifdef DEBUG
____[code]____
return ____[expression]____
#endif
//test
for (UIView *subView in [____[self.view]____ subviews])
{
NSLog(@"subView = %@", subView);
____[code]____
}
[DTContextGet().currentApplication exitAnimated:____[YES]____];
#pragma mark - private
#pragma mark ______doing
#pragma mark ______clicked
#pragma mark ______create
#pragma mark ______notif
#pragma mark - Delegates
#pragma mark - public
#pragma mark - ____[mainMark]____
#pragma mark __________[section]____
//modify by ____[author]____, begin
//reason:____[reason]____
//date:____[yyyy]____-____[mm]____-____[dd]____
____[code]____
//modify end
[[NSNotificationCenter defaultCenter] removeObserver:____[self]____
name:____[(NSString *)]____
object:____[nil]____];
[[NSNotificationCenter defaultCenter] addObserver:____[self]____
selector:____[(SEL)]____
name:____[(NSString *)]____
object:____[nil]____];
[[NSNotificationCenter defaultCenter] removeObserver:____[self]____
name:____[(NSString *)]____
object:____[nil]____];
21.nsNotificationCenterRemoveObserver或者notifRemoveObserver ------>取消监听消息
[[NSNotificationCenter defaultCenter] removeObserver:____[self]____];
[self performSelectorInBackground:____[(SEL)]____ withObject:____[nil]____];
[self performSelectorOnMainThread:____[(SEL)]____ withObject:____[nil]____ waitUntilDone:____[(BOOL)]____];
[self performSelector:____[(SEL)]____ withObject:____[nil]____ afterDelay:____[(NSTimeInterval)]____];
[self.navigationController popViewControllerAnimated:____[YES]____];
[self.navigationController popToViewController:____[vc]____ animated:____[YES]____];
[self.navigationController popToRootViewControllerAnimated:____[YES]____];
[[NSNotificationCenter defaultCenter] postNotificationName:____[name]____ object:____[nil]____];
[self.navigationController pushViewController:____[vc]____ animated:____[YES]____];
[UIView animateWithDuration:0.3f
animations:^{
____[code]____
} completion:^(BOOL finished) {
}];
[DTContextGet() startApplication:____[appId]____ params:____[params]____ animated:____[YES]____];
tools