gpt4 book ai didi

ios - 线程 1 : breakpoint 1. 2;使用 Objective-C 将 Realm 数据加载到自定义 TableView 中

转载 作者:可可西里 更新时间:2023-11-01 05:40:31 25 4
gpt4 key购买 nike

所以我最近在学习 Realm 数据库并将数据加载到我的自定义 TableView 中,我尝试使用 RLMResults 作为数组来获取数据库中的数据,并以通常的方式将存储在 RLMResults 中的元素加载到我的 TableView 中.我的 ViewController.m 是这样的:

#import "ViewController.h"
#import "customCell.h"
#import "Person.h"

@interface ViewController ()
@property RLMRealm *realm;
@property RLMResults *person;
@end

@implementation ViewController
@synthesize realm, person;
- (void)viewDidLoad {
[super viewDidLoad];

Person *one = [[Person alloc] init];
one.firstName = @"Allen";
one.lastName = @"X";

realm = [RLMRealm defaultRealm];
[realm beginWriteTransaction];
[realm addObject:one];
[realm commitWriteTransaction];

self.person = [Person allObjects];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [person count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath{
NSString *cellIdentifier = @"cellIdentifier";
customCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.firstName.text = [self.person[indexPath.row] firstName];
cell.lastName.text = [self.person[indexPath.row] lastName];
return cell;
}

@end

一旦我编译并运行它,Xcode 会说这样的话: Thread 1: breakpoint 1.2

谁能帮帮我?

最佳答案

这可能是因为您在代码的该部分设置了一个断点(您的代码旁边的列中的蓝色箭头),这可能是偶然的。 ;)

如果您单击断点并将其拖动到左侧的列中,则会将其删除,您的代码应该会在下一次构建时再次开始运行。 :)

(此外,这里的 a page on Apple's documentation 更详细地介绍了您还可以使用断点做什么。祝您好运!:))

关于ios - 线程 1 : breakpoint 1. 2;使用 Objective-C 将 Realm 数据加载到自定义 TableView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33622547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com