Read a String Back From NSUserDefaults?

Scott Stevenson sstevenson at mac.com
Mon Feb 12 23:15:40 PST 2007


On Feb 12, 2007, at 10:26 PM, Brad Carter wrote:

> box2IPAddress = [[NSUserDefaults standardUserDefaults]  
> objectForKey:BCBox2IPAddress];
>
> I get the following error when my method runs. By the way,  
> box2IPAddress is an NSString.
>
> -[NSCFString substringFromIndex:] called with out-of-bounds index.  
> For apps linked on Tiger this will raise an exception. For earlier  
> apps it will produce this one-time warning and continue with  
> existing behavior (which is undefined).

I think there's probably some relevant code we're not seeing. It's  
possible but unlikely that fetching the value alone would cause a  
bounds exception. You would probably need to be processing it in some  
way to cause this error.

Can you post a simplified sample project which reproduces the problem?

      - Scott


More information about the MacOSX-dev mailing list