Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.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 NSTokenField自动完成_Objective C_Cocoa_Autocomplete_Parsing_Nstokenfield - Fatal编程技术网

Objective c NSTokenField自动完成

Objective c NSTokenField自动完成,objective-c,cocoa,autocomplete,parsing,nstokenfield,Objective C,Cocoa,Autocomplete,Parsing,Nstokenfield,我正在创建一个使用NSTokenField的应用程序。我需要自动完成。我正在使用NSURLRequest从http://stackoverflow.com/filter/tags?_=&limit=6&q=×tamp= 其中,是当前时间戳,是要自动完成的字符串。因此,例如http://stackoverflow.com/filter/tags?_=1263657227137&q=lol&limit=6×tamp=1263657227137 答复的格式如下: javascrip

我正在创建一个使用NSTokenField的应用程序。我需要自动完成。我正在使用NSURLRequest从
http://stackoverflow.com/filter/tags?_=&limit=6&q=×tamp=

其中,
是当前时间戳,
是要自动完成的字符串。因此,例如
http://stackoverflow.com/filter/tags?_=1263657227137&q=lol&limit=6×tamp=1263657227137

答复的格式如下:

javascript|23179
jquery|16936
sql-server|11768
ruby-on-rails|8669
best-practices|7037
ruby|6722
(数字是使用此标记的次数)

我需要为用户提供一个NSTokenField下的列表,其中包含此标记列表,用户可以选择其中一个列表,也可以继续键入

有人能帮我吗?谢谢


编辑:我现在正在看Mac开发中心。我是否应该使用此方法:
tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:

这将发送给代理以查询字符串数组:

tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: 
然后,这些字符串应由
representedObject
中的
tokenField
处理(如果您只需要字符串,则不处理)

tokenField
委托中的示例:

- (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
{
    //code to find the tags strings corresponding to substring (the string typed in the token)
    //then put them in an array (returnArray)
    return returnArray;
}

tokenField
将在您键入时显示在菜单中完成的字符串。所有详细信息都在文档中。

这将发送给学员以查询字符串数组:

tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: 
然后,这些字符串应由
representedObject
中的
tokenField
处理(如果您只需要字符串,则不处理)

tokenField
委托中的示例:

- (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
{
    //code to find the tags strings corresponding to substring (the string typed in the token)
    //then put them in an array (returnArray)
    return returnArray;
}

tokenField
将在您键入时显示在菜单中完成的字符串。所有细节都在文件中。

我对你的要求有点困惑。您想在标记字段中显示标记列表以供选择,还是在它下面有一个用于标记的附加控件,当选中时,它们将显示在标记字段中?它下面是一个传统控件。我对您的要求有点困惑。是否要在标记字段中显示标记列表以供选择,或者是否在其下有一个用于标记的附加控件,当选择时,这些标记将显示在标记字段中?该控件下是一个传统控件。