Cocoa/Java: Bug in NSObject.valueForKey()?
Cocoa/Java: Bug in NSObject.valueForKey()?
- Subject: Cocoa/Java: Bug in NSObject.valueForKey()?
- From: Rams <email@hidden>
- Date: Mon, 3 Feb 2003 00:38:19 -0500
I have run into a problem with valueForKey(). I've written a small bit
of code to demonstrate it. Is this a bug, or am I just doing something
stupid? If it is a bug, how/where do I file it?
//Sample Code, results in NSRangeException
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
import java.net.*;
public class CrashDemo {
public void applicationWillFinishLaunching(NSNotification
aNotification) {
Crasher c = new Crasher();
//Works just peachy for http: ftp: mailto: or whatever
try {
c.setLocation(new URL("http:"));
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
c.valueForKey("location");
System.out.println(c.getLocation());
//With an incomplete file: though
try {
c.setLocation(new URL("file:"));
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("\nHold on to your hat!\n\n");
c.valueForKey("location");
System.out.println(c.getLocation());
}
class Crasher extends NSObject {
private URL location;
public URL getLocation() {
return location;
}
public void setLocation(URL location) {
this.location = location;
}
}
}
/********************************************************
*********** Results in the following output ***********
********************************************************/
http:
Hold on to your hat!
2003-02-03 00:20:33.037 CrashDemo[1227] Exception raised during posting
of notification. Ignored. exception: NSRangeException: [NSCFString
characterAtIndex:]: Range or index out of bounds
Stack Trace:
NSRangeException: [NSCFString characterAtIndex:]: Range or index out of
bounds
at com.apple.cocoa.foundation.NSObject.valueForKey(Native Method)
at CrashDemo.applicationWillFinishLaunching(CrashDemo.java:39)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.