Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
Hi all,

Im having a problem whereby I need to keep track of a few files on the system that my application keeps a URL reference to. The problem I am having is that I can't get any notification when these files are moved.

I tried the code below but it isn't working, the delegate methods never get called.

Code:
- (void)awakeFromNib
{
		
	NSFm=[NSFileManager defaultManager];
	
	[NSFm setDelegate:self];
	
	NSLog(@"Delegate %@", [NSFm delegate]);

	
}


- (void)fileManager:(NSFileManager *)manager willProcessPath:(NSString *)path{
	NSLog(@"File manager%@",manager);
	
}

- (BOOL)fileManager:(NSFileManager *)fileManagershouldMoveItemAtPath:(NSString *)srcPathtoPath:(NSString *)dstPath {
	
	NSLog(@"File manager");
	return YES;
}
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
If you want to track files when they are moved, you can use aliases (from Carbon). One Cocoa wrapper is NDAlias.
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
Yeah, NDAlias or similar is the way to go. As for why your code didn't work, you're fundamentally misunderstanding what NSFileManager does. It's isolated to just your application; so those delegate methods will only be called when you ask your NSFileManager instance to do something.

Also you mis-capitalized one of them.
 

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
Ok thanks,

I thought that was the problem.

Its more of a case that if they are moved I want to delete there related in my application.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.