码代码时碰到的一些小问题 & Xcode的一些使用方法
2012-09-14 15:04
696 查看
[b]我还是菜鸟,写下的记录不一定完全正确。多找资料,多google吧。[/b]
Xcode 4.3.2
1、添加Frameworks,或者看图
View Code
28、@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
在- (NSFetchedResultsController *)fetchedResultsController中调用:
第一次:0;
第二次:!=0;(在其他方法中调用)。
如果:
第一次:!=0;
第二次:!=0;(在其他方法中调用)。
猜测,刚初始化后没有执行 performFetch 操作。
29、为什么需要在Core Data 中的 Entities 之间的 Relationship 指定 Inverse?
Core Data uses bidirectional relationship information to maintain the consistency of the object graph (hence the Consistency Error) and manage undo and redo information. If you leave a relationship without an inverse, you imply that you will take care of the object graph consistency and undo/redo management. The Apple documentation strongly discourages this, however, especially in the case of a tomany relationship. When you don’t specify an inverse relationship, the managed object at the other end of the relationship isn’t marked as changed when the managed object at this end of the relationship changes.(摘自《Pro.Core.Data.for.iOS. Second.Edition》)
30、是否需要实现 NSMangedobject 子类中的比如 add<Key>Object 和 remove<Key>s 方法?
描述:
不需要。
Managed Object Accessor Methods,《Core Data Programming Guide》。
There should typically be no need for you to provide your own implementation of these methods, unless you want to support scalar values. The methods that Core Data generates at runtime are more efficient than those you can implement yourself.
31、《Core Data’s default date value》
默认值可以使用带双引号的词,形式如“now”,但是时间在编译时决定,而不是运行时。
32、Core Data:在使用NSFetchedResultsController的情况下,在self.managedObjectContext保存后,没有保存在到持久性存储中?
应该这样:
原因:
摘自Apple‘s SampleCode。
33、error occurred when I execute “self.course.referenceBooks.count”?
描述见链接。
原因:由于手动建立的model file,关系名(books)和Course类中的属性不一致导致。
34、Creating Source Code to Implement a Custom Managed Object Class
创建源代码用于实现自定义的 Managed Object 类。
35、在创建源代码用于实现自定义的 Managed Object 类的时候,有着一个选项:use scalar properties for primitive data types
使用 scalar properties ,Core Data 不会动态生成 accessor methods,即需要自己手动实现。
链接。
文档链接。
36、Insert a Table Header View (tableHeaderView) in StoryBoard。
拖动控件至导航栏与表视图之间。类似的界面可通过在ViewController中添加视图控件和表示图控件,但效果没之间插入表头视图好。
![](http://pic002.cnblogs.com/images/2012/266130/2012102219332094.png)
37、在使用UITableView时,当数据发生改变后,最好执行 [self.tableView reloadData];;其他,见4
38、隐藏self.navigationItem.backBarButtonItem
Xcode 4.5.2
39、在UIScrollView中添加图片,在代码中能实现预期的效果,而在SB中好UIScrollView则会使它的frame变形,它的高度比图片的高度高很多时才不报错。
。
Xcode 4.3.2
1、添加Frameworks,或者看图
View Code
#pragma mark - UIAlertViewDelegate - (void)willPresentAlertView:(UIAlertView *)alertView { [self.textField resignFirstResponder]; } // 某处 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"不能为空" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show];
28、@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
在- (NSFetchedResultsController *)fetchedResultsController中调用:
NSLog(@"%i", _fetchedResultsController.fetchedObjects.count);
第一次:0;
第二次:!=0;(在其他方法中调用)。
如果:
[_fetchedResultsController performFetch:&error]; // add this line NSLog(@"%i", _fetchedResultsController.fetchedObjects.count);
第一次:!=0;
第二次:!=0;(在其他方法中调用)。
猜测,刚初始化后没有执行 performFetch 操作。
29、为什么需要在Core Data 中的 Entities 之间的 Relationship 指定 Inverse?
Core Data uses bidirectional relationship information to maintain the consistency of the object graph (hence the Consistency Error) and manage undo and redo information. If you leave a relationship without an inverse, you imply that you will take care of the object graph consistency and undo/redo management. The Apple documentation strongly discourages this, however, especially in the case of a tomany relationship. When you don’t specify an inverse relationship, the managed object at the other end of the relationship isn’t marked as changed when the managed object at this end of the relationship changes.(摘自《Pro.Core.Data.for.iOS. Second.Edition》)
30、是否需要实现 NSMangedobject 子类中的比如 add<Key>Object 和 remove<Key>s 方法?
描述:
@interface Employee (DirectReportsAccessors) - (void)addDirectReportsObject:(Employee *)value; - (void)removeDirectReportsObject:(Employee *)value; - (void)addDirectReports:(NSSet *)value; - (void)removeDirectReports:(NSSet *)value; @end
不需要。
Managed Object Accessor Methods,《Core Data Programming Guide》。
There should typically be no need for you to provide your own implementation of these methods, unless you want to support scalar values. The methods that Core Data generates at runtime are more efficient than those you can implement yourself.
31、《Core Data’s default date value》
默认值可以使用带双引号的词,形式如“now”,但是时间在编译时决定,而不是运行时。
32、Core Data:在使用NSFetchedResultsController的情况下,在self.managedObjectContext保存后,没有保存在到持久性存储中?
应该这样:
NSError *error; NSManagedObjectContext *addingManagedObjectContext = controller.managedObjectContext; if (![addingManagedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } if (![[self.fetchedResultsController managedObjectContext] save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); }
原因:
The new managedObject is associated with the add controller's managed object context. This means that any edits that are made don't affect the application's main managed object context -- it's a way of keeping disjoint edits in a separate scratchpad. Saving changes to that context, though, only push changes to the fetched results controller's context. To save the changes to the persistent store, you have to save the fetch results controller's context as well.
摘自Apple‘s SampleCode。
33、error occurred when I execute “self.course.referenceBooks.count”?
描述见链接。
原因:由于手动建立的model file,关系名(books)和Course类中的属性不一致导致。
34、Creating Source Code to Implement a Custom Managed Object Class
创建源代码用于实现自定义的 Managed Object 类。
35、在创建源代码用于实现自定义的 Managed Object 类的时候,有着一个选项:use scalar properties for primitive data types
使用 scalar properties ,Core Data 不会动态生成 accessor methods,即需要自己手动实现。
链接。
文档链接。
36、Insert a Table Header View (tableHeaderView) in StoryBoard。
拖动控件至导航栏与表视图之间。类似的界面可通过在ViewController中添加视图控件和表示图控件,但效果没之间插入表头视图好。
![](http://pic002.cnblogs.com/images/2012/266130/2012102219332094.png)
37、在使用UITableView时,当数据发生改变后,最好执行 [self.tableView reloadData];;其他,见4
38、隐藏self.navigationItem.backBarButtonItem
self.navigationItem.hidesBackButton = NO;
Xcode 4.5.2
39、在UIScrollView中添加图片,在代码中能实现预期的效果,而在SB中好UIScrollView则会使它的frame变形,它的高度比图片的高度高很多时才不报错。
。
相关文章推荐
- Xcode中git的使用方法介绍与"Please tell me who you are"问题的解决方案
- 使用ECharts碰到的一些问题和解决方法
- Xcode中git的使用方法介绍与"Please tell me who you are"问题的解决方案
- Xcode有许多快捷键,这些快捷键在Xcode的工具栏里都有标注,学会使用这些快捷键可以大大的提高你的编程效率。本文来给大家介绍一些Xcode常用快捷键,设置方法:Xcode主菜单->Xcode->P
- cordova + ionic 使用中碰到的一些问题及其解决方法
- Xcode中git的使用方法介绍与"Please tell me who you are"问题的解决方案
- 使用vim配置方案spf13中碰到的一些问题
- Oracle 12c安装方法及一些使用问题
- 使用Layered Window遇到的一些问题及解决方法
- 使用elasticsearch遇到的一些问题以及解决方法(不断更新)
- 使用php缺少加密扩展mcrypt等相关问题的一些解决方法
- 使用AsyncHttpClient碰到的问题及解决方法
- 在xcode 6.4 中使用swift和object-c混合编程,同时通过cocoapods进行管理的一些问题和解决办法
- Android学习笔记03:学习过程中碰到的一些问题及解决方法
- android github 下载的代码使用方法及问题解决
- 使用pageoffice 编辑文档和转pdf碰到的问题与解决方法
- FAQ&Tips:Xilinx ISE在Win10下使用的一些问题
- cordova + ionic 使用中碰到的一些问题
- 关于Xcode一些常用插件的安装使用问题
- mybatis使用过程遇到的一些问题及解决方法