【问题标题】:Objective C pointer use [duplicate]Objective C指针使用[重复]
【发布时间】:2011-06-30 20:34:34
【问题描述】:

可能的重复:
What's your preferred pointer declaration style, and why?
Placement of the asterisk in Objective-C

有什么区别

NSString* foo = @"I'm a string";

NSString *foo = @"I'm a string";

我一直使用后一种方式,但不确定是否真的有区别。

谢谢!

【问题讨论】:

    标签: objective-c pointers


    【解决方案1】:

    没有。完全没有区别。这与 C 语言中的相同。它们都是指向NSString 的指针。

    有些人更喜欢后一种形式,因为它明确了指针是什么变量。即:

    int* i, j;
    // i is a pointer
    // j is not a pointer
    
    int *i, j;
    // makes clearer that i is a pointer while j is not
    
    int *i, *j; // both pointers...
    

    查看有关该主题的C-FAQ entry

    【讨论】:

    • 是否有行业标准的做法?只是用户偏好吗?
    • 没有。根本没有标准。这种讨论可以追溯到旧的 C 时代。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 2012-02-25
    • 1970-01-01
    • 2018-11-03
    • 2011-05-19
    • 1970-01-01
    相关资源
    最近更新 更多