Calling functions question

Hello masters;

I’m new with AppleScriptObjC.
My function setWallpaper have to be called in AppleScript giving the Wallpaper and the screen (screenSelected),
but i don’t know how to call the function correctly.

I tried with:

tell WorkersController to setWallpaper_Wallpaper_screenSelected_(Desktop1, MyScreen)


WorkersController's setWallpaper_Wallpaper_screenSelected_(Desktop1, MyScreen)


WorkersController's setWallpaper_screenSelected_(Desktop1, MyScreen)

and others I already forgot…

The functions:

MyScreensFunction() returns the number of screen

set WorkersController to (current application's class "Worker"'s alloc)'s init

set MyScreen to (WorkersController's MyScreensFunction())

- (void)setWallpaper: (NSString *)Wallpaper:(NSNumber *)screenSelected{
    NSWorkspace *sws = [NSWorkspace sharedWorkspace];
    NSURL *image = [NSURL fileURLWithPath:Wallpaper];
    NSError *err = nil;
	NSScreen *iterScreen;
	NSArray *screens = [NSScreen screens];
	for (iterScreen in screens)
		if ([[iterScreen deviceDescription] objectForKey:@"NSScreenNumber"] == screenSelected)
			NSDictionary *opt = [sws desktopImageOptionsForScreen:iterScreen];        
			[sws setDesktopImageURL:image forScreen:iterScreen options:opt error:&err];
			if (err) {
				NSLog(@"%@",[err localizedDescription]);
				NSNumber *scr = [[iterScreen deviceDescription] objectForKey:@"NSScreenNumber"];
				NSLog(@"Set %@ for space %i on screen %@",[image path],[self spaceNumber],scr);

Thanks guys

I have not tried to set set the wall paper, but the following code works without any additional class etc

log current application’s NSWorkspace’s sharedWorkspace()'s desktopImageOptionsForScreen_(current application’s NSScreen’s screens’s objectAtIndex_(0))

log current application’s NSWorkspace’s sharedWorkspace()'s desktopImageURLForScreen_(current application’s NSScreen’s screens’s objectAtIndex_(0))

to set the the wallpaper use:
current application’s NSWorkspace’s sharedWorkspace()'s setDesktopImageURL_forScreen_options_error_( “fill your options in here”)



That line doesn’t make sense.