Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSURLHandle propertyForKey

NSURLHandle propertyForKey
Thread Tools
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Oct 4, 2002, 03:06 AM
 
Im trying to use NSURLHandle writeProperty to set a property on an NSURLHandle ive created. The documentation states that writeProperty returns a BOOL indicating whether the modification was successful. Mine returns YES, as in it was successfull. In my next line of code, I test to see if I can query my newly created property for key. It returns nil.


begin code

- (void)getSelectedSongNSString *)theSongURL {
NSURLHandle *songHandle = [[NSURL URLWithString:theSongURL] URLHandleUsingCache:NO];
[songHandle writeProperty:[theSongURL lastPathComponent] forKey:@"songName" ];
if ([songHandle propertyForKey:@"songName"] == nil) {
[bit is:YES label:@"its nil"];
}else {
[bit is:YES label:[songHandle propertyForKey:@"songName"]];
}
[songHandle addClient: self];
[songHandle loadInBackground];
}

end code

I cant retrieve the property that I have successfully set. I need to do this because I need to know which file is being downloaded, so I know what to name the file Im about to write to disk. Can anyone shed some light on this or suggest an alternative way to know what url the handle represents once URLHandleResourceDidFinishLoading?


btw: bit is:BOOL labelNSString *) is a nifty little class my friend wrote that simply pops up an alert with title. It can also be used like this:

begin code

[bit is:[songHandle writeProperty:[theSongURL lastPathComponent] forKey:@"songName" ] label:@"some label"];

end code

I tell you all this because I figured you might not know what that "bit" was all about. I use it like NSLog().
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Oct 4, 2002, 07:15 AM
 
Originally posted by 3R1C:
Im trying to use NSURLHandle writeProperty to set a property on an NSURLHandle ive created. The documentation states that writeProperty returns a BOOL indicating whether the modification was successful. Mine returns YES, as in it was successfull. In my next line of code, I test to see if I can query my newly created property for key. It returns nil.


Code:
- (void)getSelectedSong:(NSString *)theSongURL { NSURLHandle *songHandle = [[NSURL URLWithString:theSongURL] URLHandleUsingCache:NO]; [songHandle writeProperty:[theSongURL lastPathComponent] forKey:@"songName" ]; if ([songHandle propertyForKey:@"songName"] == nil) { [bit is:YES label:@"its nil"]; }else { [bit is:YES label:[songHandle propertyForKey:@"songName"]]; } [songHandle addClient: self]; [songHandle loadInBackground]; }
I cant retrieve the property that I have successfully set. I need to do this because I need to know which file is being downloaded, so I know what to name the file Im about to write to disk. Can anyone shed some light on this or suggest an alternative way to know what url the handle represents once URLHandleResourceDidFinishLoading?


btw: bit is:BOOL label:(NSString *) is a nifty little class my friend wrote that simply pops up an alert with title. It can also be used like this:

Code:
[bit is:[songHandle writeProperty:[theSongURL lastPathComponent] forKey:@"songName" ] label:@"some label"];
I tell you all this because I figured you might not know what that "bit" was all about. I use it like NSLog().
The problem could be in the string you're getting... check to see whether [theSongURL lastPathComponent] is itself nil.
[vash:~] banana% killall killall
Terminated
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Oct 4, 2002, 01:53 PM
 
I did. its not.
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Oct 4, 2002, 11:43 PM
 
could it be that writeproperty is for objects on the remote machine? There MUST be a way to ask an nsurlhandle what url it represents once its loaded.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2