Ok so I'm fairly new to objective c and i'm building a concordance class, inside the class i got a method which adds a word from a book into a a _ListofPtrsToUniqueWords, uniqueWord is another class i built for storing the word being cataloged, well in c++ my method Adds the UniqueWord to an Array of Unique Words, if it already exist its skips the word but it add a line number to the _CurrentLineArray list, this is the method i used on 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);
}
}
Now i'm trying to do the same in Objective C but i don't understand what this symbol does "->", my friend just recommended i do this but i don't understand what it does and how can i implament this in Objective 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)];
}
}
I hope i give you guys enough information on this code, thank you