Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何评价苹果';Doxygen的s块扩展?_Objective C_Cocoa_Doxygen_Objective C Blocks - Fatal编程技术网

Objective c 如何评价苹果';Doxygen的s块扩展?

Objective c 如何评价苹果';Doxygen的s块扩展?,objective-c,cocoa,doxygen,objective-c-blocks,Objective C,Cocoa,Doxygen,Objective C Blocks,。我想知道生成文档的语法是什么。我找不到任何提示-也不在doxygen配置文件(版本1.7.2)中。 更新:版本1.7.5于2011年8月14日发布。我仍然没有找到如何为Apple块编写文档。看看1.7.1和1.7.2之间的差异,我相信这一行的意思是,在识别块类型时,Doxygen扫描仪已经更新为支持Apple的块语法。例如,您可以像这样记录函数指针typedef: /// /// This is a typedef for a function pointer type. /// It ta

。我想知道生成文档的语法是什么。我找不到任何提示-也不在doxygen配置文件(版本1.7.2)中。

更新:版本1.7.5于2011年8月14日发布。我仍然没有找到如何为Apple块编写文档。

看看1.7.1和1.7.2之间的差异,我相信这一行的意思是,在识别块类型时,Doxygen扫描仪已经更新为支持Apple的块语法。例如,您可以像这样记录函数指针typedef:

///
/// This is a typedef for a function pointer type. 
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
/// 
typedef void (*MyFunctionPtrType)(NSUInteger p1, id<Foo> p2);
///
/// This is a typedef for a block type. 
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
/// 
typedef void (^MyBlockType)(NSUInteger p1, id<Foo> p2);
///
///这是函数指针类型的typedef。
///它接受一个整数参数,一个采用协议Foo的id,并且没有返回值。
/// 
typedef void(*MyFunctionPtrType)(整数p1,id p2);
并获得如下输出:

对其扫描仪的更改似乎增加了对块typedef的支持,如下所示:

///
/// This is a typedef for a function pointer type. 
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
/// 
typedef void (*MyFunctionPtrType)(NSUInteger p1, id<Foo> p2);
///
/// This is a typedef for a block type. 
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
/// 
typedef void (^MyBlockType)(NSUInteger p1, id<Foo> p2);
///
///这是块类型的typedef。
///它接受一个整数参数,一个采用协议Foo的id,并且没有返回值。
/// 
typedef void(^MyBlockType)(整数p1,id p2);
事实上,使用最新版本的Doxygen,可以产生如下输出:

///
/// This is a typedef for a function pointer type. 
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
/// 
typedef void (*MyFunctionPtrType)(NSUInteger p1, id<Foo> p2);
///
/// This is a typedef for a block type. 
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
/// 
typedef void (^MyBlockType)(NSUInteger p1, id<Foo> p2);

您可以记录块类型的全局变量,但其行为有点不稳定。例如:

///
/// This is a global variable of type MyBlockType. It logs the parameters to the console.
///
MyBlockType myGlobalBlock = ^(NSUInteger p1, id<Foo> p2){

    /**
     * This is a block comment inside my block, which would get 
     * concatted into the "in body" description if this were a function.
     * but won't be because this is a block.
     */
    NSLog(@"p1: %lu p2: %@", p1, p2);
};

///
/// This is the definition for the function MyFunction
/// 
void MyFunction(NSUInteger p1, id<Foo> p2)
{
    /**
     * This is a block comment inside my function, which will get 
     * concatted into the "in body" description.
     */

    NSLog(@"p1: %lu p2: %@", p1, p2);
}
///
///这是MyBlockType类型的全局变量。它将参数记录到控制台。
///
MyBlockType myGlobalBlock=^(整数p1,id p2){
/**
*这是我的区块内的区块注释,它将
*如果这是一个函数,则合并到“体内”描述中。
*但不会,因为这是一个街区。
*/
NSLog(@“p1:%lu p2:%@”,p1,p2);
};
///
///这是函数MyFunction的定义
/// 
void MyFunction(整数p1,id p2)
{
/**
*这是我函数中的一个块注释,它将
*浓缩到“体内”描述中。
*/
NSLog(@“p1:%lu p2:%@”,p1,p2);
}
我得到了这个输出,这有点,有点不是我想要的:


幸运的是,我怀疑块类型的全局变量在实践中不是那么常见的一种模式,因此Doxygen在处理它们方面不是非常出色这一事实并不是什么大问题。似乎没有任何证据表明在差异中进一步增加了对块的支持。

我不知道Obj-C,但下面是如何标记源,以便在类型块不是接口成员的情况下生成此输出。使用带有相关接口名称的
@related
标记作为其目标:

/**
 * @related MyService
 *
 * The completion handler invoked when `unsubscribe` returns.
 */
typedef void(^MyServiceUnsubscribeCompletion)(NSError *error);


@interface MyService : NSObject
...
@end
迪米特里自己提供了解决方案: