有一篇关于为您自己的框架设置错误域的SO帖子,但是关于为您自己的项目/应用程序设置错误域和自定义错误代码的最佳做法是什么?
例如,假设您正在使用具有大量验证的核心数据密集型应用程序,您是否应该坚持使用"现成的"核心数据错误代码(例如NSManagedObjectValidationError来自CoreDataErrors.h),或者您应该创建自己的错误代码MyAppErrors.h并定义错误更具特异性(即MyAppValidationErrorInvalidCombinationOfLimbs?
创建自定义错误域和错误代码集可能会明显消除代码歧义,但维护过多是否需要担心错误代码编号冲突?或者还有其他问题吗?
我在iPhone应用程序中使用NSFetchedResultsController,我想知道是否有一些简单的方法来获取所有部分返回的总行数.
而不是获取[[fetchedResultsController sections] count]然后循环遍历每个部分以获得它的计数,它可以在一行中完成吗?
谢谢!
我在网上冲浪寻找一个很好的效果,在Android上翻页,似乎不是一个.由于我正在学习这个平台,能够做到这一点似乎是一件好事.
我设法在这里找到一个页面:http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html
- (void)deform
{
Vertex2f vi; // Current input vertex
Vertex3f v1; // First stage of the deformation
Vertex3f *vo; // Pointer to the finished vertex
CGFloat R, r, beta;
for (ushort ii = 0; ii < numVertices_; ii++)
{
// Get the current input vertex.
vi = inputMesh_[ii];
// Radius of the circle circumscribed by vertex (vi.x, vi.y) around A on the x-y plane
R = sqrt(vi.x * vi.x + pow(vi.y - A, 2));
// …Run Code Online (Sandbox Code Playgroud) 我注意到在那里的很多参考资料中,我看到很多时候,变量在.h文件中被命名为_variable,然后在.m文件中被@ synthesize.
@synthesize variable = _variable;
Run Code Online (Sandbox Code Playgroud)
为什么这样做?我错过了什么?
谢谢!
我正在尝试找出使用UISegmentedControliPhone应用程序的"最佳"方式.我已经在stackoverflow上阅读了一些帖子并看到了一些人的想法,但我无法理清这样做的最佳方法.我所指的帖子是:
从UISegmentedControl更改视图 以及 如何使用UISegmentedControl切换视图?
似乎选项是:
UIView并根据所选的段左/右或上/下动画UITabBarController来换掉子视图 - 看起来很傻cellForRowAtIndex根据所选的段选项从不同的数据源或部分填充表(不是我的应用程序的情况)那么哪种方法最适合子视图/非表格方法?哪个最容易实现?你能分享一些示例代码吗?
谢谢!
我正在开发一个iPad应用程序,它从Web下载CSV文件并将文件解析为NSMutableArray.(我正在使用另一篇文章中建议的http://www.macresearch.org/cocoa-scientists-part-xxvi-parsing-csv-data中的代码).
当我在模拟器中运行时,一切都运行良好,但是当我在设备上运行时,我收到以下错误:
Program received signal: “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
(gdb)
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会弹出这个?谷歌在这里没有帮助我...... :(
谢谢!
我正在使用Dave DeLong 用于Objective-C 的优秀CHCSVParser和一个非常长的.CSV文件,并且在使用它时遇到了一些麻烦.我会使用这个arrayWithContentsOfCSVFile方法,但是我在iPhone上运行代码并将整个文件解析到内存中会占用更多内存.
在我的下面的代码中,解析器打开文档并完美地调用委托方法,但是在委托中的哪个位置我会在每行之后停止并访问数据(以创建Core Data对象并将其保存到数据存储中)?我假设它会在- (void) parser:(CHCSVParser *)parser didEndLine:(NSUInteger)lineNumber,但是如何NSArray在完成线路时从解析器中获取(或其他)数据?
到目前为止,这是我的代码:
//
// The code from a method in my view controller:
//
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *manager = [NSFileManager defaultManager];
NSError *err = nil;
NSArray *fileList = [manager contentsOfDirectoryAtPath:documentsDirectory error:&err];
NSString *fileName = [fileList objectAtIndex:1];
NSURL *inputFileURL = [NSURL fileURLWithPath: [documentsDirectory stringByAppendingPathComponent:fileName]];
NSStringEncoding encoding = 0;
CHCSVParser *p = [[CHCSVParser alloc] initWithContentsOfCSVFile:[inputFileURL path] …Run Code Online (Sandbox Code Playgroud) 我见过很多与代表有关的帖子,我想知道引用它们的正确方法.假设我有一个声明为的对象:
@interface MyViewController : UITableViewController {
id delegate;
}
@property (nonatomic, retain) id delegate;
@end
Run Code Online (Sandbox Code Playgroud)
在生命周期中MyViewController,它将响应与用户的交互来调用其委托的方法.
什么时候摆脱一个实例MyViewController,是否delegate需要release在实现的dealloc方法中使用ivar,因为它被声明了retain?
或者相反,delegate甚至应该保留?也许它应该是@property (nonatomic, assign) id delegate?根据Apple的文档:
retain ...您通常将此属性用于标量类型(如NSInteger和CGRect),或者(在引用计数环境中)用于您不拥有的对象(如委托).
通常情况下,我只是按照文档的说法去做,但我看到很多代码都会调用retain代理.这只是"糟糕的代码吗?" 我在这里请专家......处理这个问题的正确方法是什么?
我有一个带有自己.xib的UIViewController,我想使用UISegmentedControl在屏幕的下半部分显示不同的信息.我在容器的.xib中创建了一个UIView,并将它连接到detailView容器的UIViewController中调用的UIView属性.
然后我在IB中创建了三个.xib文件,一个用于每个段需要在该detailView区域中显示的视图.
我现在卡住了,因为我不知道如何加载和卸载相应的.xib文件到该detailView区域.我就在这里:
- (void)segmentValueChanged:(id)sender {
switch ([sender selectedSegmentIndex]) {
case 0:
// Unload whatever is in the detailView UIView and
// Load the AddressView.xib file into it
break;
case 1:
// Unload whatever is in the detailView UIView and
// Load the ContactsView.xib file into it
break;
case 2:
// Unload whatever is in the detailView UIView and
// Load the NotesView.xib file into it
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
那么如何填写空白并正确卸载/加载detailView UIView?
谢谢! …
今天下午我正在使用Xcode并在我的设备上调试应用程序就好了.当我从办公室回家并插上手机以继续工作时,XCode将不再允许我在我的设备上进行调试.我收到的错误是:
Error Starting Executable. No provisioned iOS device is connected.
Run Code Online (Sandbox Code Playgroud)
所以我跳到主办单位,这就是我所看到的:

什么给出了什么?有人见过这个吗?
谢谢!
iphone ×7
objective-c ×4
core-data ×3
xcode ×2
android ×1
cocoa ×1
cocoa-touch ×1
csv ×1
ios ×1
ipad ×1
math ×1
nserror ×1
subview ×1
transition ×1
uiview ×1