Fix isServiceAvailable issue (solves #11)

This commit is contained in:
Sebastián Katzer 2014-07-13 11:26:58 +02:00
parent 02e39320d5
commit 03b70956ba

View File

@ -36,20 +36,8 @@
@end
@interface APPPrinter ()
// Getter property for the `isPrintingAvailable` method
@property (readonly, getter=isPrintingAvailable) BOOL isPrintingAvailable;
// Getter property for the `printController` method
@property (readonly, getter=printController) UIPrintInteractionController* printController;
@end
@implementation APPPrinter
@synthesize isPrintingAvailable, printController;
/*
* Checks if the printing service is available.
*
@ -59,9 +47,10 @@
- (void) isServiceAvailable:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult;
BOOL isAvailable = [self isPrintingAvailable];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsBool:isPrintingAvailable];
messageAsBool:isAvailable];
[self.commandDelegate sendPluginResult:pluginResult
callbackId:command.callbackId];
@ -75,15 +64,14 @@
*/
- (void) print:(CDVInvokedUrlCommand*)command
{
if (!self.isPrintingAvailable)
{
if (!self.isPrintingAvailable) {
return;
}
NSArray* arguments = [command arguments];
NSString* content = [arguments objectAtIndex:0];
UIPrintInteractionController* controller = printController;
UIPrintInteractionController* controller = [self printController];
[self adjustSettingsForPrintController:controller];
[self loadContent:content intoPrintController:controller];
@ -178,7 +166,8 @@
return NO;
}
return printController && [UIPrintInteractionController isPrintingAvailable];
return [self printController] && [UIPrintInteractionController
isPrintingAvailable];
}
@end