Nothing shows up?


#1

I’ve input the code on page 171/172 and as far as I can tell the output isn’t showing me the file that takes me to the text at the bottom of the page. Maybe I’m missing something, maybe I’ve typed in the code wrong. Either way its getting to me.

This is my code

[code]int main (int argc, const char * argv[])
{

@autoreleasepool {
    
    NSMutableArray *stocks = [[NSMutableArray alloc] init];
    
    NSMutableDictionary *stock;
    
    stock = [NSMutableDictionary dictionary];
    [stock setObject:@"APPL"
              forKey:@"symbol"];
    [stock setObject:[NSNumber numberWithInt:200]
              forKey:@"shares"];
    [stocks addObject:stock];
    
    stock = [NSMutableDictionary dictionary];
    [stock setObject:@"GOOG"
              forKey:@"symbol"];
    [stock setObject:[NSNumber numberWithInt:160]
              forKey:@"shares"];
    [stocks addObject:stock];
    
    [stocks writeToFile:@"/tmp/stocks.plist"
             atomically:YES];
    
}
return 0;

}

[/code]

And this is my output

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000 sharedlibrary apply-load-rules all [Switching to process 5398 thread 0x0]

Could anyone lend me some direction?


#2

That program doesn’t print anything to the output. It silently creates a file at /tmp/stocks.plist


#3

Ok cool. Theres obviously stuff I’ve missed within the file chapter, gonna go back and give it another go.


#4

I know this topic is old but I wanted to post as a reminder that Lion (and probably Mountain Lion) hides the tmp folder. Even a search using Spotlight won’t find the file. To view the file you open finder and select GO -> Go to Folder, then type the /TMP. It’s been a while since I was back on page 151 and I forgot this step. I had to search the book to find it. Hopefully the next person who comes here won’t make the same silly mistake and waste as much time as I did.

You learn (or re-learn) something new every day! :wink:


#5

OK I run the program, and get a message saying Finished running stocks : stocks.

However, when I go to Go–>Go to Folder, and search for tmp, the stocks.plist file is not in there. I double-checked the path - here’s a copy straight from my code:

    [stocks writeToFile:@"tmp/stocks.plist" atomically:YES];

Why isn’t the file showing up? I can’t find it anywhere.


#6

never mind - just realized i’m missing a slash!!!