我对目标c,xcode和ios开发一般都很陌生。我只是想创建一个简单的TODO应用程序,但我没有运气我的支票完成。每次我点击一个项目,我在控制台日志中得到一个(lldb)和一个线程1:断点1.1我不知道它指的是什么。我的断点出现在最后一行[tableView deselectRowAtIndexPath:indexPath animated:YES];
我不知道这里发生了什么。任何帮助将不胜感激。
#import "TDOViewController.h"
@interface TDOViewController () <UIAlertViewDelegate>
@property (nonatomic) NSMutableArray *items;
@end
@implementation TDOViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Handles list of items
self.items = @[@{@"name" : @"Take out the trash", @"category" : @"home"}, @{@"name" : @"Shoes", @"category" : @"home"}].mutableCopy;
// Handles navigation bar
self.navigationItem.title = @"To-Do List";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewItem:)];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Adding Items
- (void)addNewItem:(UIBarButtonItem *) sender {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"New ToDo Item" message:@"Enter name of new ToDo Item" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add Item", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != alertView.cancelButtonIndex) {
UITextField * itemNameField = [alertView textFieldAtIndex:0];
NSString *itemName = itemNameField.text;
NSDictionary *item = @{@"name" : itemName, @"category" : @"home"};
[self.items addObject:item];
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:self.items.count - 1 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
#pragma mark - Table view datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.items.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"TodoItemRow";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSDictionary *item = self.items[indexPath.row];
cell.textLabel.text = item[@"name"];
if ([item[@"completed"] boolValue]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableDictionary *item = [self.items[indexPath.row] mutableCopy];
BOOL completed = [item[@"completed"] boolValue];
item[@"completed"] = @(!completed);
self.items[indexPath.row] = item;
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = ([item[@"completed"] boolValue]) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
答案 0 :(得分:1)
您可以删除断点导航器中的断点。如果您想调试代码,请按照“https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/debugging_tools.html”
链接进行操作希望它有所帮助。