小编ksc*_*ins的帖子

初始化NSDictionary

以下是我的.h文件:

    NSDictionary *originalValues;
    @property (nonatomic, retain) NSDictionary *originalValues;
Run Code Online (Sandbox Code Playgroud)

这是用于初始化NSDictionary的.m文件.

@synthesize originalValues;

- (void)viewDidLoad {

// copy original values when view loaded
originalValues = [[NSDictionary alloc] initWithObjectsAndKeys:place.city, @"city", place.cuisine, @"cuisine",
                place.latitude, @"latitude", place.longitude, @"longitude", place.name, @"name", place.rating,
                @"rating", place.state, @"state", place.street, @"street", place.telephone, @"telephone",
                place.timesVisited, @"times visited", place.uppercaseFirstLetterOfName, @"first letter", 
                place.website, @"website", place.zipcode, @"zipcode", nil];
}
Run Code Online (Sandbox Code Playgroud)

问题是只有前四个对象和键被添加.之后,它们不会被添加到以place.name,@"name"开头的字典中.我在整个字典上做了一个NSLog,输出的唯一的东西是我提到的前四个值,然后我在place.name上做了一个NSLog,它输出一个值,所以我知道也应输出这个键/值对.这里有什么我想念的吗?我很好奇为什么所有的值都没有最初添加到NSDictionary中?

xcode objective-c nsdictionary ios

26
推荐指数
3
解决办法
6万
查看次数

核心数据崩溃 - 无法识别的选择器

我已经看过其他关于无法识别的选择器错误的帖子,但是关于以下方法中自动生成的代码没有任何内容:

- (void)tableView:(UITableView *)tableView commitEditingStyle:forRowAtIndexPath:
Run Code Online (Sandbox Code Playgroud)

当我滑动删除时调用此方法,当我点击删除按钮时出现以下错误:

- [Vehicle removeObjectFromGasUpsAtIndex:]:无法识别的选择器发送到实例0x8172c60

我的NSManagedObject类Vehicle有一个名为gasUps的NSOrderedSet变量,当我要删除它时,它应响应此消息.或者我想.

这是崩溃的整个方法:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
   if (editingStyle == UITableViewCellEditingStyleDelete) {
    // need to delete gas up and not vehicle
    int row = [indexPath row];

    //[self.selectedVehicle removeObjectFromGasUpsAtIndex:row];
    [self.selectedVehicle removeObjectFromGasUpsAtIndex:row];
    NSError *error = nil;
    if (![self.managedObjectContext save:&error]) {
         // Replace this implementation with code to handle the error appropriately.
         // abort() causes the application to generate a crash log and terminate. You should not use this function in a …
Run Code Online (Sandbox Code Playgroud)

core-data ios

5
推荐指数
1
解决办法
3029
查看次数

使用Parse.com通过iOS应用程序创建新用户时发送电子邮件

我想在每次在iOS应用中创建新用户时发送电子邮件.我正在使用Parse.com作为我的后端,并且一直在阅读有关Cloud Code的内容.我假设我可以使用它来监视对象创建,并启动一个函数,以便在数据库中创建特定对象(用户)时发送电子邮件.我知道我可以在CloudCode中创建一个函数,然后在创建用户后在我的iOS应用程序中调用此函数,但我希望能够在不向App Store提交更新的情况下执行相同的操作.有没有办法在不提交新二进制文件的情况下完成此操作?

ios parse-platform

0
推荐指数
1
解决办法
289
查看次数