• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Odd string becoming nil error...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Odd string becoming nil error...


  • Subject: Odd string becoming nil error...
  • From: jjoonathan <email@hidden>
  • Date: Fri, 26 Nov 2004 18:25:32 -0700

Ok, I have an app that writes out to a file in a
x=y
z=a

type format (this is for something else; I cannot change this to a plist). So, I made a way of writing to it. First, I load the contents of the file into a mutable string called "filed". This works fine. Then, I apply the following method for each individual thing I need to write (It need to be like this too, the things are often in different orders).


- (void)writeString:(NSString *)writestr toStat:(NSString *)stat
{
NSScanner *scanner = [NSScanner scannerWithString:filed];
[scanner scanUpToString:[NSString stringWithFormat:@"\n%@=",stat] intoString:nil];
if ([scanner isAtEnd]) return;
int left = [scanner scanLocation] + strlen([stat cString]) + 2;
[scanner setScanLocation:[scanner scanLocation] + 1];
[scanner scanUpToString:@"\n" intoString:nil];
int right = [scanner scanLocation] - left;
if (writestr != nil) [filed replaceCharactersInRange:NSMakeRange(left,right) withString:writestr];
}

I call it using the following code:

[self writeString:[maxSpectators stringValue] toStat:@"MaxSpectators"];
[self writeString:[maxTeamSize stringValue] toStat:@"MaxTeamSize"];
[self writeString:[minHonor stringValue] toStat:@"MinHonor"];
etc.

Now, the confusing part is that "writestr" is always nil when it is actually being used in the writeString method, even if I pass it a real string (I have confirmed this by having it log various things; I am quite sure of this). The [textfield stringvalue]s will log out just fine, meaning that is not the issue. Even if I pass it something like @"dssadassa", it will still mysteriously become nil. I have tried cleaning and rebuilding, even restarting (nobody else gets this issue, even on the same binaries), and nothing helps. Any suggestions?

jjoonathan
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSDictionary and binding
  • Next by Date: Re: Using Keychain for storing archived object ?
  • Previous by thread: Re: NSDictionary and binding
  • Next by thread: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
  • Index(es):
    • Date
    • Thread