我昨天刚开始使用CoreData,我疯了:(我创建了一个使用CoreData的项目(勾选方框 - 使用CoreData).创建实体,然后为所有实体创建NSManagedObject类(我猜他们创建实体的'setter'和'getter'方法).
现在,我在AppDeletegate中#imported所有这些类,并在我的applicationDidFinishLaunching方法中写了这个:
(订阅是申请中的实体之一)
NSManagedObjectContext *context = [self managedObjectContext];
Subscriptions *sbs = (Subscriptions *)[NSEntityDescription insertNewObjectForEntityForName:@"Subscriptions" inManagedObjectContext:context];
[sbs setTitle:@"OK"];
[sbs setType:@"Tag"];
[sbs setCode:@"cars"];
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Couldn't create the subscription");
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到此错误
[NSManagedObject setTitle:]:无法识别的选择器发送到实例0x6160550
我不知道为什么会这样.请帮忙!!!在此先感谢大家!
添加Subscriptions
Subscriptions.h 的标题
@interface订阅:NSManagedObject {
}
@property(nonatomic,retain)NSString*Type;
@property(nonatomic,retain)NSDecimalNumber*Read;
@property(nonatomic,retain)NSString*Title;
@property(nonatomic,retain)NSString*Code;
@property(nonatomic,retain)NSDecimalNumber*New;
@结束
我什么都没改变.就像Xcode创建它一样.
我写的这个应用程序有一个问题.
我正在UITabBar我的应用程序窗口中设置并在视图文件中设置图标.但是,当我运行应用程序时,第一个图标显示(因为视图已加载,我猜),其他图标在我点击它们之前不会显示.
我需要用self.tabBarItem其他方法实现viewDidLoad吗?
在此先感谢大家!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
tabBar = [[UITabBarController alloc] init];
SubscriptionsController *subscriptionsController = [[SubscriptionsController alloc] init];
FavoritesController *favoritesController = [[FavoritesController alloc] init];
CategoriesController *categoriesController = [[CategoriesController alloc] init];
TagsController *tagsController = [[TagsController alloc] init];
HelpScreenController *helpScreenController = [[HelpScreenController alloc] init];
tabBar.viewControllers = [NSArray arrayWithObjects:
subscriptionsController,
favoritesController,
categoriesController,
tagsController,
helpScreenController,
nil
];
[window addSubview:tabBar.view];
// Override point for customization after application launch.
[window makeKeyAndVisible];
return YES;
}
//The View
- …Run Code Online (Sandbox Code Playgroud) 我正在尝试激活UITableView的编辑模式.当我点击"编辑"按钮时,它会变为"完成",但圆形的红色减号不会显示在表格中.我发布了下面的一些方法.应用程序委托创建了一个选项卡栏,选项卡内的视图具有导航控制器.一切都是在代码中完成的,很少用nib文件完成.怎么了?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [ikub.subscriptions count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
int i = [indexPath row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
Subscriptions *s = [ikub.subscriptions objectAtIndex:i];
cell.textLabel.text = [s title];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ artikuj te rinj, %@ artikujt te lexuar", [s new], [s read]];
if (deleteActive) {
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
- …Run Code Online (Sandbox Code Playgroud) 嘿大家,
当我加载我第一次写的应用程序时,我得到了一个毫无意义的错误.
_NSZombie_NSKeyValueUndefinedGetter类在两者中都实现了?和?? ?? 将使用两者之一.哪一个未定义.
以前有人有这个问题吗?只有在启用NSZombies时才会发生这种情况.
在此先感谢大家.
我正在尝试编写一个iPhone应用程序,我遇到了问题.
我在一个类中声明了一个常量作为app委托
#define ikub (iKubMobileAppDelegate *)[[UIApplication sharedApplication] delegate]
Run Code Online (Sandbox Code Playgroud)
当我需要获取数组的大小时,这是应用程序的实例变量
[ikub.subscriptions count]
Run Code Online (Sandbox Code Playgroud)
我收到错误访问未知'订阅'的getter方法.
我不确定为什么会这样.
请帮忙!!!!
我有一个使用UITabBarController的应用程序,在每个选项卡中我都有导航控制器.我希望在另一个视图中发生操作后重新加载其中一个视图,以便当用户返回到该视图时 - 它会更新.可能吗?
谢谢你!
我正在尝试做一个iOS应用程序,当我按CMD + I启动仪器检查内存泄漏时,模拟器在几次手势后冻结,仪器也是如此.
有时一分钟(或更长时间)后它会起作用,但这让我疯狂:(
我有Mac OS Lion和Xcode 4(Lion版本从Apple的开发门户网站下载).
请帮忙!
提前致谢!
ios ×7
iphone ×6
objective-c ×3
core-data ×2
delegates ×1
instruments ×1
memory-leaks ×1
nszombie ×1
sqlite ×1
uitabbaritem ×1
uitableview ×1
uiview ×1
xcode ×1