Tôi đã tự dạy mình Mục tiêu-C trong khoảng 6 tháng và thích sử dụng ngôn ngữ rất nhiều. Tuy nhiên tôi đã không tìm thấy bất kỳ tiêu chuẩn mã hóa tốt, vì vậy mã tôi viết luôn luôn kết thúc lên trông giống như một mớ hỗn độn không phù hợp.Tiêu chuẩn mã hóa mục tiêu-C?
Những điều như quy ước đặt tên chỉ được thực hiện tốt, nhưng khoảng cách, thụt đầu dòng và chiều rộng dòng (không thể?) 80 không hoạt động tốt như vậy.
Bạn sử dụng quy ước nào với Objective-C?
Dưới đây là một ví dụ nhỏ của một cái gì đó không hoạt động:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.navigationItem.leftBarButtonItem =
[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self.parentViewController
action:@selector(done:)] autorelease];
NSString* units = [[NSString alloc] initWithFormat:@"%@", @"oz"];
NSString* optionOne = [[NSString alloc] initWithFormat:@"[%d%@] Calculate", 100, units];
self.options = [[NSMutableArray alloc] initWithObjects:
optionOne,
@"Configure Portions",
@"Configure Notifications",
@"Help",
nil];
[units release];
[optionOne release];
[tableView reloadData];
}
return self;
}
https: // github.com/raywenderlich/target-c-style-guide # ngôn ngữ – thesummersign