尝试为我的 NSManagedObject 子类编写自定义描述方法,而不是在 self.myvarname 中打印该数据,而是打印出“Myvarname”或打印 self.userCount 打印“UserCount”?
按照这个例子:http ://brandontreb.com/objective-c-tutorial-helpful-debugging-by-overriding-the-description-method/
另外,为什么当我在 xcode 控制台中输入“po myroominstance.name”或“po myroominstance.usage”时,它会说没有找到属性(给定下面的类)?
这是我的课:
.h
===================
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface Rooms : NSManagedObject
{
NSString *name;
NSNumber *capacity;
NSString *descr;
NSString *usage;
}
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * capacity;
@property (nonatomic, retain) NSString * descr;
@property (nonatomic, retain) NSString * usage;
@end
.M
==================
#import "Rooms.h"
@implementation Rooms
@dynamic name;
@dynamic capacity;
@dynamic descr;
@dynamic usage;
-(NSString *) description
{
return [NSString stringWithFormat:@"ID: %@ Name: %@ Website: %n",
usage ,descr,name];
}
@end
更新1:================================================ ==========
====== My break point is on this line ==========
Room *myRoom = [Room findFirst];
NSLog(@"The room name is %@", myRoom.name);
================================================
如果我在上面的 NSlog 行中断,顺便打印出“房间名称是名称”,然后在控制台中键入“po myRoom.name”,我得到“名称”。如果我输入“po myRoom.descr”,我会得到“Descr”。