Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Another Cocoa Question

Another Cocoa Question
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
Nov 3, 2003, 11:02 PM
 
Ok I have another question that I cannot find an answer to. Hopefully it will be as easy as the last one. Anyways, in the program I am writing, I can run it in Project Builder, but when I try to run it outside of Project Builder, it always crashes... Maybe I have a setting set wrong or something but it is very frustrating. Anyone have an answer? Thanks!
     
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
Nov 3, 2003, 11:46 PM
 
Well.. I fired up gdb and got the followin error:

2003-11-03 23:44:44.134 Program[4632] An uncaught exception was raised
2003-11-03 23:44:44.134 Program[4632] *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
2003-11-03 23:44:44.135 Program[4632] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value

Know I know I am trying to insert a nil value somewhere... So, time to find it! If you have a suggestion, please let me know!
     
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
Nov 4, 2003, 10:32 AM
 
It *sounds* like the type of error you get when an object is being prematurely released. Try doing some research on NSZombie, I've found it to be very helpful for debugging memory problems.
     
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
Nov 4, 2003, 02:50 PM
 
Ok, I found my error. However, now my program refuses to read a text file unless I run it in Project Builder... I call the file to open via C and scan through till I find what I need. Is there an easy way to do this in Objective-C?
     
Mac Enthusiast
Join Date: Nov 2001
Status: Offline
Reply With Quote
Nov 4, 2003, 11:30 PM
 
If this is what you're looking for:
Code:
NSString *fileContents = [NSString stringWithContentsOfFile:@"/ThePath/To/TheFile.txt"];
And then you could you NSScanner (or even simple NSString and NSArray methods), but if performance is important then maybe you could stick to C.
     
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
Nov 5, 2003, 08:09 AM
 
Yeah i rewrote everything last night in Cocoa... It runs faster with less code now! Thanks!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:22 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2