Most to all of the classes in Objective-C returns nil if passed nil or some error, but NSURL throws an exception. Specifically, the method [NSURL fileURLWithPath].
It is documented: "Passing nil for this parameter produces an exception."
But, can anyone explain Apple would throw an exception instead of returning nil?
It is calling a method on nil that is allowed. Many methods can throw exceptions if given an invalid argument. For example see NSMutableArray's addObject:.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With