加入“-&燃气轮机&引用;在目标C中 >所以我对目标C来说是相当新的,我正在构建一个和谐类,在这个类中,我得到了一个方法,它把一个单词从一个书中添加到一个单词表中,UngWordWord是我用来存储被编录的单词的另一个类,在C++中,我的方法将唯一的单词添加到一个唯一的单词数组中,如果它已经存在,它会跳过这个单词,但会在_CurrentLineArray列表中添加一个行号,这就是我在C上使用的方法++ /* Attempts to add a word to the concordance. If it already exists, the existing entry is updated with the new line. */ void Concordance::add(const string word, const int line) { int insertion, index; UniqueWord *uw = new UniqueWord(word, line);//creates the uniqueWord object insertion = newIndex(*uw, index);//figures out where my word belongs in my array to be alphabetized if (insertion == -1) { // The word already exists - add a line number. delete uw; ListOfUniqueWordsPtrs[index]->addLine(line);//I'm trying to do this in Objective C. //My friend recommended i do this but i never asks what exactly does it do, addLine is a Unique word method } else { ListOfUniqueWordsPtrs.insert(ListOfUniqueWordsPtrs.begin() + insertion, uw); } }

加入“-&燃气轮机&引用;在目标C中 >所以我对目标C来说是相当新的,我正在构建一个和谐类,在这个类中,我得到了一个方法,它把一个单词从一个书中添加到一个单词表中,UngWordWord是我用来存储被编录的单词的另一个类,在C++中,我的方法将唯一的单词添加到一个唯一的单词数组中,如果它已经存在,它会跳过这个单词,但会在_CurrentLineArray列表中添加一个行号,这就是我在C上使用的方法++ /* Attempts to add a word to the concordance. If it already exists, the existing entry is updated with the new line. */ void Concordance::add(const string word, const int line) { int insertion, index; UniqueWord *uw = new UniqueWord(word, line);//creates the uniqueWord object insertion = newIndex(*uw, index);//figures out where my word belongs in my array to be alphabetized if (insertion == -1) { // The word already exists - add a line number. delete uw; ListOfUniqueWordsPtrs[index]->addLine(line);//I'm trying to do this in Objective C. //My friend recommended i do this but i never asks what exactly does it do, addLine is a Unique word method } else { ListOfUniqueWordsPtrs.insert(ListOfUniqueWordsPtrs.begin() + insertion, uw); } },c++,objective-c,class,object,methods,C++,Objective C,Class,Object,Methods,现在我正试图在目标C中做同样的事情,但我不明白这个符号是做什么的“->”,我的朋友刚刚建议我这样做,但我不明白它是做什么的,我怎么能在目标C中实现它 -(void) add:(NSString *)currentWordBeingCatalog and:(NSNumber*)CurrentLineNumber{ NSInteger insertion, index=0; UniqueWord *CurrentWord=[[UniqueWord alloc] initWithString:cur

现在我正试图在目标C中做同样的事情,但我不明白这个符号是做什么的“->”,我的朋友刚刚建议我这样做,但我不明白它是做什么的,我怎么能在目标C中实现它

-(void) add:(NSString *)currentWordBeingCatalog and:(NSNumber*)CurrentLineNumber{
NSInteger insertion, index=0;

UniqueWord *CurrentWord=[[UniqueWord alloc] initWithString:currentWordBeingCatalog andline:CurrentLineNumber];
insertion=[self NewIndexToFindOutIf:CurrentWord is:[NSNumber numberWithLong:index]];
if(insertion==-1){
    /*If the word already exist, it would delete the word and add the line number to the _linenumber NSMutableArray*/
    CurrentWord=NULL;
    [_ArrayOfPtrsToUniqueWords objectAtIndex:index]->[CurrentWord addALineNumberToCurrentLineNumberArray:CurrentLineNumber]];//This is where i'm trying to figure out what to do
}else{
    [_ArrayOfPtrsToUniqueWords insertObject:CurrentWord atIndex:(0+insertion)];
 }

}

我希望我给大家提供足够的信息,谢谢你,

>代码> > >代码>在ObjuleC中做了类似于C++的操作,它放置在一个指向一个对象的指针之后,访问它的实例变量(C++中也被用来调用方法,而在Objtovi-C中,<代码> [SimultMeNoDe]使用语法)。但是,在Objective-C中,属性通常优先于

->
符号。它在代码中的使用似乎是错误的,罗布·梅洛夫做了一个很好的纠正它的工作。

<代码> > > >代码>在ObjuleC中做了类似于C++的操作,它放置在一个指向对象的指针之后,访问它的实例变量(C++中也被用来调用方法,而在Objtovi-C中,<代码> [SimultMeNeNo])使用语法)。但是,在Objective-C中,属性通常优先于
->
符号。它在代码中的使用似乎是错误的,rob mayoff对其进行了很好的纠正。

这是您正在寻找的语法:

[[_ArrayOfPtrsToUniqueWords objectAtIndex:index] addALineNumberToCurrentLineNumberArray:CurrentLineNumber];
。。。也就是说,你要求数组返回它的一个元素,然后你要求该元素添加一个行号

如果您愿意,可以这样分解:

UniqueWord *existingWord = [_ArrayOfPtrsToUniqueWords objectAtIndex:index];
[existingWord addALineNumberToCurrentLineNumberArray:CurrentLineNumber];
您还可以直接在
NSArray
NSMutableArray
对象上使用数组订阅,因此如果
\u ArrayOfPtrsToUniqueWords
NSMutableArray
,您可以执行以下操作:

UniqueWord *existingWord = _ArrayOfPtrsToUniqueWords[index];
[existingWord addALineNumberToCurrentLineNumberArray:CurrentLineNumber];
或者这个:

[_ArrayOfPtrsToUniqueWords[index] addALineNumberToCurrentLineNumberArray:CurrentLineNumber];

这是您要查找的语法:

[[_ArrayOfPtrsToUniqueWords objectAtIndex:index] addALineNumberToCurrentLineNumberArray:CurrentLineNumber];
。。。也就是说,你要求数组返回它的一个元素,然后你要求该元素添加一个行号

如果您愿意,可以这样分解:

UniqueWord *existingWord = [_ArrayOfPtrsToUniqueWords objectAtIndex:index];
[existingWord addALineNumberToCurrentLineNumberArray:CurrentLineNumber];
您还可以直接在
NSArray
NSMutableArray
对象上使用数组订阅,因此如果
\u ArrayOfPtrsToUniqueWords
NSMutableArray
,您可以执行以下操作:

UniqueWord *existingWord = _ArrayOfPtrsToUniqueWords[index];
[existingWord addALineNumberToCurrentLineNumberArray:CurrentLineNumber];
或者这个:

[_ArrayOfPtrsToUniqueWords[index] addALineNumberToCurrentLineNumberArray:CurrentLineNumber];

如果你的名字在两者之间更相似,可能会更容易,但这是你想要的吗
[[u ArrayOfPtrsToUniqueWords objectAtIndex:index]addalineumbertocurrentlinenumberray:CurrentLineNumber]
您不需要
->
。通过
objectAtIndex
获取对象,然后通过在对象周围添加另一组
[]
并添加消息名来调用该对象。以
[[UniqueWord alloc]initWithString…
为例。如果您的命名在两者之间更相似,可能会更容易,但这就是您想要的吗?
[[u ArrayOfPtrsToUniqueWords objectAtIndex:index]addalineumbertocurrentlinenumerary:CurrentLineNumber]
您不想要
->
。通过
objectAtIndex
获取对象,然后通过在对象周围添加另一组
[]
并添加消息名来调用该对象。查看
[[UniqueWord alloc]initWithString…
作为一个例子。他评论中@crashmtr的例子是我要找的吗?对不起,我真的不知道符号做了什么。他评论中@crashmtr的例子是我要找的吗?对不起,我真的不知道符号做了什么谢谢这就是我要找的确切解释谢谢。这就是我想要的确切解释。