Tag: 实例

获取自定义类的实例数

我在xcode中创build了一个自定义类: PaperPack并定义了2个即时variables: title和author – 然后我分配了2个类的实例如下: PaperPack *pack1 = [[PaperPack alloc] init]; pack1.title = @"Title 1"; pack1.author = @"Author"; PaperPack *pack2 = [[PaperPack alloc] init]; pack1.title = @"Title 2"; pack1.author = @"Author"; 那么我如何计算并返回与该类创build的实例的数量?

是否有可能dynamic改变代码中的类的名称与variables?

我有这个function: – (NSString*) getId:(id)id_field withColumn:(int)test_column withTable:(NSString *) tableName //renvoyer le label { NSError *error = nil; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:tableName inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSArray *fetchedObjects = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; for (<tableName of class> *info in fetchedObjects) { if (test_column == LBL2_CLMN) { NSLog(@"info.id :%@", info.id); if ([info.id compare:id_field] […]

iOS:其他替代实例variables?

我有一个其他人写的项目,我已经接pipe了它,希望能够让应用程序更好。 我遇到了一个问题: 来自一个class级: 我写_customclass.variable。 CustomClass是另一个类,variables是一个属性,是inttypes的。 我在这个类中获得了variables的值,但是当我将它改为self.customclass.variable时,我总是得到0.是否有其他替代方法从其他类中获取值? (一个) @property (readwrite)int boxSpacing; (b)中 @synthesize boxSpacing; (C) – (id)initWithCoder:(NSCoder *)aDecoder { self.boxSpacing = 10; }