小编use*_*809的帖子

结构体指针运算符猜想(理论)

结构体指针的使用非常频繁,因此有一个特殊的运算符:->。下面的表达式是等价的:

(*x).y
 x->y
Run Code Online (Sandbox Code Playgroud)

将此运算符简单地视为如下定义的预处理器宏是否公平:

#define (x)-> (*(x).)

为什么或者为什么不?或者它从一开始就被编码为运算符 - 这有何不同/优势?

只是好奇。

c syntax struct pointers operators

3
推荐指数
1
解决办法
1606
查看次数

保存,文档扩展和首选项(Info.plist)

我有一个简单的基于文档的Cocoa应用程序调用"RaiseMan".当我去保存文件时,控制台中会显示以下消息:

-[NSDocumentController fileExtensionsFromType:] is deprecated, and does not work when passed a uniform type identifier (UTI). If the application didn't invoke it directly then the problem is probably that some other NSDocument or NSDocumentController method is getting confused by a UTI that's not actually declared anywhere. Maybe it should be declared in the UTExportedTypeDeclarations section of this app's Info.plist but is not. The alleged UTI in question is "com.bignerdranch.raiseman-doc".

如果我将当前文件保存为"测试",则会显示一个以.plist打开的文件,并且不会使用Raiseman应用程序打开.如果我将其保存为"Test.rsmn"(明确键入扩展名),则将其保存为Raiseman类型文件,但是当我重新打开文件时,我无法访问任何用户首选项或首选项面板(.xib) .

背景:我目前正在通过Aaron Hillegass的Mac OS X编程,第13章......

xcode objective-c save plist xib

3
推荐指数
1
解决办法
758
查看次数


Objective-C 中参数的命名约定

在 Objective-C 中命名参数时,如果我对类似的方法使用相同的名称,这是否重要 - 也就是说,对于文档/易读性是可取的?例如:

@interface Zookeeper : Employee

-(void) washAnimal:(Animal *)someAnimal;
-(void) feedAnimal:(Animal *)someAnimal;
-(void) trainAnimal:(Animal *)someAnimal;

...
Run Code Online (Sandbox Code Playgroud)

或者,应该是这样的:

@interface Zookeeper : Employee

-(void) washAnimal:(Animal *)animalToBeWashed;
-(void) feedAnimal:(Animal *)animalToBeFed;
-(void) trainAnimal:(Animal *)animalToBeTrained;

...
Run Code Online (Sandbox Code Playgroud)

谢谢!

parameters coding-style objective-c naming-conventions

2
推荐指数
1
解决办法
162
查看次数

打破switch语句

我总是不得不在break开关声明中; 简单地用分号;退出是不安全的?

switch ( (rand() % 2) ) {
    case 0:
    // Do foo;
    break;
    case 1:
    // Do nothing
    ;
    default:
    ;
}
Run Code Online (Sandbox Code Playgroud)

c scope objective-c break switch-statement

1
推荐指数
2
解决办法
1746
查看次数