I have an odd question (to me, anyway).
I am calling a function within my Objective-C program and am passing in three arguments... a home cooked object, an NSMutableArray, and an NSString.
The function prototype looks like this....
int LoadNoteTableArray (Entryfile* EntryfileName,
NSMutableArray* NSMutableArrayInputEntry, NSString* title_string);
I call it from within main like this...
Entryfile* Entryfile1 = [[Entryfile alloc] init];
NSMutableArray *NoteTableArray = [[NSMutableArray alloc] initWithCapacity:1];
NSString* title_string;
title_string = @"test string";
checkerror = LoadNoteTableArray (Entryfile1, NoteTableArray, title_string);
And it is set up in the function like this....
int LoadNoteTableArray (Entryfile* Entryfile1, NSMutableArray* NoteTableArray,
NSString* title_string) {
I am able to use the object Entryfile1 and change it in the function using the objects various methods and those changes are seen in the main program. I am able to add entries into NoteTableArray and see then back in the main program. However, changes to the NSString do not get reflected back in the main program. I am able to see title_string as @"test string" at the start of the function. It is set to something else in the function but that value never makes it back to the main program.
I am confused at the difference between these notations and objects.
Thoughts?
Ok.... code snippers... from the main routine...
checkerror = LoadConfigTableArray (Configfile1, ConfigEntryArray);
title_string = @"test string";
checkerror = LoadNoteTableArray (Entryfile1, NoteTableArray, &title_string);
[NoteTableArray sortUsingSelector:@selector(compareNoteEntryTime:)];
checkerror = RemediateNoteTableArray (NoteTableArray);
checkerror = WriteOutTimeFromNoteTableArray (NoteTableArray, ConfigEntryArray, title_string);
[NoteTableArray sortUsingSelector:@selector(compareNoteIDandMarkTime:)];
checkerror = WriteOutNotesFromNoteTableArray (NoteTableArray, ConfigEntryArray);
Please be aware that check error will be used to catch error conditions reported from the various functions after I get this problem worked out...
You asked for it... you got it... Toyota... here is the function... I'm not cleaning up the spacing for this posting site. Some of the code was play code so if you want to go after it that's ok but be aware that you're not helping me much. It reads a text file (Mac or Windows), parses certain lines into objects, and loads them into an object array.
int LoadNoteTableArray (Entryfile* Entryfile1, NSMutableArray* NoteTableArray, NSString** title_string) {
NSString* tokenclass;
NSString* previous_tokenclass;
NSString* token;
NSString* savedheaderid;
NSString* response;
NSString* tempstring;
NSString* tempstring2;
NSString* token_xx;
NSString* entryfile1path;
NSString* entryfile1name;
NSString* responseok;
NSNumber* temp_MarkTime;
NoteTableEntry* NoteTableEntrytemp;
char firstline;
char first_id_found;
int duplicate_count;
int arrayCount;
int loop_count;
entryfile1path = [NSString stringWithString: @"PATH"];
entryfile1name = [NSString stringWithString: @"notes"];
responseok = [Entryfile1 OpenEntryFile: entryfile1path withdatafilename: entryfile1name];
if ([responseok isEqualToString:@"ERROR"]) {return 1;};
if ([responseok isEqualToString:@"LAST"]) {return 2;};
firstline = 'N';
first_id_found = 'N';
tokenclass = nil;
*title_string = nil;
do {
if (tokenclass == nil) {previous_tokenclass = nil;}
if (tokenclass != nil) {previous_tokenclass = [NSMutableString stringWithString: tokenclass];}
tokenclass = nil;
token = [Entryfile1 GetNextToken];
if (token == nil) {break;};
tokenclass = [Entryfile1 ClassifyToken:token];
if ([tokenclass isEqualToString: @"i"]) {
[NoteTableArray addObject:[NoteTableEntry initNoteTableEntryForID:token]];
firstline = 'Y';
first_id_found = 'Y';
savedheaderid = response;
duplicate_count = 0;
previous_tokenclass = nil;
continue;};
if (([tokenclass isEqualToString: @"s"]) & (first_id_found == 'N')) {
*title_string = token;
continue;};
if (first_id_found == 'N') {continue;};
if (([tokenclass isEqualToString: @"t"]) & ([previous_tokenclass isEqualToString: @"t"] == FALSE)) {
arrayCount = [ NoteTableArray count ];
arrayCount--;
NoteTableEntrytemp = [NoteTableArray objectAtIndex:arrayCount];
[NoteTableEntrytemp AddTimeEntry:savedheaderid withtimestring:token];
continue;};
if (([tokenclass isEqualToString: @"t"]) & ([previous_tokenclass isEqualToString: @"t"] == TRUE)) {
duplicate_count++;
arrayCount = [ NoteTableArray count ];
arrayCount--;
NoteTableEntrytemp = [NoteTableArray objectAtIndex:arrayCount];
[NoteTableArray addObject:[NoteTableEntry initNoteTableEntryForID:[NoteTableEntrytemp NoteID]]];
arrayCount = [ NoteTableArray count ];
arrayCount--;
NoteTableEntrytemp = [NoteTableArray objectAtIndex:arrayCount];
[NoteTableEntrytemp AddTimeEntry:savedheaderid withtimestring:token];
[NoteTableEntrytemp AddNoteType:savedheaderid withnotetype:@"t"];
continue;};
if ([tokenclass isEqualToString: @"d"]) {
arrayCount = [ NoteTableArray count ];
arrayCount--;
NoteTableEntrytemp = [NoteTableArray objectAtIndex:(arrayCount - duplicate_count)];
[NoteTableEntrytemp AddNoteType:savedheaderid withnotetype:token];
if ([token isEqualToString: @"n"] & (arrayCount > 0)) {
NoteTableEntrytemp = [NoteTableArray objectAtIndex:(arrayCount - duplicate_count - 1)];
temp_MarkTime = NoteTableEntrytemp.TimeMark;
NoteTableEntrytemp = [NoteTableArray objectAtIndex:(arrayCount - duplicate_count)];
[NoteTableEntrytemp setTimeMark: temp_MarkTime];
}
continue;};
if (([tokenclass isEqualToString: @"s"]) & (firstline == 'Y')) {
arrayCount = [ NoteTableArray count ];
arrayCount--;
loop_count = 0;
do {
NoteTableEntrytemp = [NoteTableArray objectAtIndex:(arrayCount - loop_count)];
[NoteTableEntrytemp AddNoteHeader:savedheaderid withnoteheader:token];
if (loop_count == duplicate_count) {
tempstring = [NSString stringWithString: @" - XX:XX"];
tempstring2 = [token stringByAppendingString:tempstring];
token_xx = tempstring2;
[NoteTableEntrytemp AddNoteBody:savedheaderid withnotebody:token_xx];}
else {
[NoteTableEntrytemp AddNoteBody:savedheaderid withnotebody:token];};
loop_count++;
} while (loop_count <= duplicate_count);
firstline = 'N';
continue;};
if (([tokenclass isEqualToString: @"s"]) & (firstline == 'N')) {
arrayCount = [ NoteTableArray count ];
arrayCount--;
NoteTableEntrytemp = [NoteTableArray objectAtIndex:(arrayCount - duplicate_count)];
[NoteTableEntrytemp AddNoteBody:savedheaderid withnotebody:token];
firstline = 'N';
continue;};
} while (token);
return 0;
}