English 中文(简体)
页: 1 如何用几节添加新物体的数据?
原标题:iPhone4 Core Data how to insert a new object with section number?

我试图将新物体插入我的核心数据结构,并知道它们属于哪一部分。

在此,我要在新记录中增加一个部分。

-(void)insertNewReminderWithSequenceNumber:(int)sequenceNumber
{
    // Create a new instance of the entity managed by the fetched results controller.
    NSManagedObjectContext *context = [self.remindersController managedObjectContext];
    NSEntityDescription *entity = [[self.remindersController fetchRequest] entity];
    Reminder *newManagedObject = (Reminder*)[NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
    newManagedObject.sequenceNumber = [NSNumber numberWithInt:sequenceNumber];

}

在此,我要指出,我将这一节定为零。

-(Reminder*)getReminderAtIndex:(int)index
{
    NSIndexPath* temp = [NSIndexPath indexPathForRow:index inSection:0];
    Reminder* reminder  = nil;
    @try {
       reminder= [self.remindersController objectAtIndexPath:temp];
    }
    @catch (NSException *exception) {
        NSLog(@"Exception accessing event at index: %i", index);
        return nil;
    }
    @finally {

    }

    return reminder;
}

www.un.org/Depts/DGACM/index_spanish.htm 我怎么能将物体插入核心数据,以便用包含栏号和行号的索引检索。

谢谢!

最佳回答

简单使用<代码>objectAtIndexPath:

Reminder *reminder = (Reminder *) [self.fetchedResultsController 
   objectAtIndexPath];

这与你如何将物体插入受管制物体无关。 相反,你必须具体说明你的章节,编号为。 页: 1

问题回答

暂无回答




相关问题
iPhone Core Data Recursive Relationships

I m having some trouble with a recursive relationship in core data. I ve got a managed object called a "SearchCategory", and that category can have "Categories" and it can also have a "Category." In ...

Plist Hierarchy and All Option

I have a string of data in a plist, which I ve got to display, hierarchically like this: Menu>Chapter>SubChapter>item>item details This might be super simple, in my initial menu, how would I have ...

Fetched Properties v Relationships (Core Data - iPhone)

I m a new iPhone developer (of about 4 months or so) who is starting to look at Core Data. In the "Beginning iPhone 3 Development" book by Dave Mark it mentions that the main difference between ...

Cocoa Core Data newbie how-tos

I am one of the great unwashed masses of .NET developers keen to try their hands at Mac OS X development. At the moment I am trying to figure out the various elements of Cocoa and getting a bit stuck ...

中间储存的核心数据

我想将核心数据作为输入数据库服务器更大数据集的切身。

Limit the returned resultset in CoreData

In CoreData, if I want to limit the returned resultset to 100, is it enough to just set the fetch limit to 100, or do I need to set the fetch batch size to 100 as well?

热门标签