I have an object that defines a property as an NSURL:
@interface fcpElement : NSObject
@property (copy) NSString* elementName;
@property (copy) NSURL* elementPath;
@property (copy) NSURL* elementParent;
@property () BOOL elementIsHidden;
@property (copy) NSString* elementType;
-(id)initWithName : (NSString*) elementName path: (NSURL*) elementPath parent: (NSURL*) elementParent hiddenValue: (BOOL) elementIsHidden type: (NSString*) elementType;
@end
In my app controller I create an NSMutableArray and populate it with my objects using my init… method.
I then have a button which calls a method on the app controller which creates a new NSURL by calling the instance variable from an object in the array, as follows:
for(currentElement in _finalCutData) {
NSURL *currentElementPath = [currentElement elementPath];
Eventually I am wanting to do a comparison to see if this new URL is equal to another, but I always get errors that stop my program if I do anything like the following:
NSURL *currentElementPathAbsolute = [currentElementPath absoluteURL];
with the error: -[__NSCFString absoluteURL]: unrecognized selector sent to instance
If I add a breakpoint it says that currentElementPath is an invalid pointer. But if I NSLog [currentElement elementPath] I get the URL contained within.
How do I get the URL from my instance variable such that I can use it? Am I using the wrong parameter types in my property declarations? Or is it something else?
currentElementPathis anNSString, not anNSURL. What does theelementPathmethod do? I don't see it in the docs - is it something you wrote?currentElementPath, then its initialization hasn't happened yet, so you'd need to step once (i.e., “do this line”) before the variable will have a value for you to print. The alternative is to set the breakpoint any subsequent line in the method; I would set it on the very next line.absoluteURLmessage. More specifically, I think it's something in between those two points, namelycurrentElementPath's declaration and theabsoluteURLmessage, that you didn't show. Please edit your question to include all of the code between the declaration ofcurrentElementPathand the use of it in theabsoluteURLmessage.