diff --git a/plugin.xml b/plugin.xml
index 670773c..3eae0df 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -75,6 +75,9 @@
+
+
+
diff --git a/src/ios/APPPrinter.m b/src/ios/APPPrinter.m
index ecfbe9b..6f2f8f7 100755
--- a/src/ios/APPPrinter.m
+++ b/src/ios/APPPrinter.m
@@ -21,13 +21,12 @@
#import "APPPrinter.h"
#import "APPPrinterItem.h"
-#import "APPPrinterInfo.h"
#import "APPPrinterPaper.h"
#import "APPPrinterLayout.h"
+#import "UIPrintInteractionController+APPPrinter.h"
@interface APPPrinter ()
-@property (retain) NSDictionary* settings;
@property (nonatomic) UIPrinter *previousPrinter;
@end
@@ -82,8 +81,6 @@
NSMutableDictionary* settings = command.arguments[1];
settings[@"callbackId"] = command.callbackId;
- self.settings = settings;
-
[self printContent:content withSettings:settings];
}];
}
@@ -100,7 +97,7 @@
choosePaper:(NSArray *)paperList
{
APPPrinterPaper* paperSpec = [[APPPrinterPaper alloc]
- initWithDictionary:_settings[@"paper"]];
+ initWithDictionary:ctrl.settings[@"paper"]];
return [paperSpec bestPaperFromArray:paperList];
}
@@ -114,7 +111,7 @@
cutLengthForPaper:(UIPrintPaper *)paper
{
APPPrinterPaper* paperSpec = [[APPPrinterPaper alloc]
- initWithDictionary:_settings[@"paper"]];
+ initWithDictionary:ctrl.settings[@"paper"]];
return paperSpec.length || paper.paperSize.height;
}
@@ -157,34 +154,6 @@
});
}
-/**
- * Adjusts the settings for the print controller.
- *
- * @param view The view which content to print.
- * @param settings The print job specs.
- *
- * @return A ready to use print controller instance.
- */
-- (UIPrintInteractionController *) prepareControllerWithSettings:(NSDictionary *)settings
-{
- UIPrintInfo* printInfo = [APPPrinterInfo printInfoWithDictionary:settings];
- NSDictionary* ui = settings[@"ui"];
-
- UIPrintInteractionController* ctrl =
- [UIPrintInteractionController sharedPrintController];
-
- ctrl.printInfo = printInfo;
- ctrl.delegate = self;
-
- if (ui)
- {
- ctrl.showsNumberOfCopies = ![ui[@"hideNumberOfCopies"] boolValue];
- ctrl.showsPaperSelectionForLoadedPapers = ![ui[@"hidePaperFormat"] boolValue];
- }
-
- return ctrl;
-}
-
/**
* Loads the content into the print controller.
*
@@ -199,7 +168,9 @@
__block id item;
UIPrintInteractionController* ctrl =
- [self prepareControllerWithSettings:settings];
+ [UIPrintInteractionController sharedPrintControllerWithSettings:settings];
+
+ ctrl.delegate = self;
if ([self strIsNullOrEmpty:content])
{
@@ -444,4 +415,3 @@
}
@end
-
diff --git a/src/ios/UIPrintInteractionController+APPPrinter.h b/src/ios/UIPrintInteractionController+APPPrinter.h
new file mode 100644
index 0000000..211be6c
--- /dev/null
+++ b/src/ios/UIPrintInteractionController+APPPrinter.h
@@ -0,0 +1,28 @@
+/*
+ Copyright 2013 appPlant GmbH
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+@interface UIPrintInteractionController (APPPrinter)
+
++ (instancetype) sharedPrintControllerWithSettings:(NSDictionary *)settings;
+
+@property (nonatomic, retain) NSDictionary *settings;
+
+@end
diff --git a/src/ios/UIPrintInteractionController+APPPrinter.m b/src/ios/UIPrintInteractionController+APPPrinter.m
new file mode 100644
index 0000000..1729ef6
--- /dev/null
+++ b/src/ios/UIPrintInteractionController+APPPrinter.m
@@ -0,0 +1,70 @@
+/*
+ Copyright 2013 appPlant GmbH
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#include "APPPrinterInfo.h"
+#include "UIPrintInteractionController+APPPrinter.h"
+
+#import
+
+@implementation UIPrintInteractionController (APPPrinter)
+
+static char UIP_SETTINGS_KEY;
+
+@dynamic settings;
+
+#pragma mark -
+#pragma mark Init
+
++ (instancetype) sharedPrintControllerWithSettings:(NSDictionary *)settings
+{
+ NSDictionary* ui = settings[@"ui"];
+
+ UIPrintInteractionController* ctrl =
+ UIPrintInteractionController.sharedPrintController;
+
+ ctrl.printInfo = [APPPrinterInfo
+ printInfoWithDictionary:settings];
+
+ ctrl.settings = settings;
+
+ if (ui)
+ {
+ ctrl.showsNumberOfCopies = ![ui[@"hideNumberOfCopies"] boolValue];
+ ctrl.showsPaperSelectionForLoadedPapers = ![ui[@"hidePaperFormat"] boolValue];
+ }
+
+ return ctrl;
+}
+
+#pragma mark -
+#pragma mark Private
+
+- (void) setSettings:(NSDictionary *)settings
+{
+ objc_setAssociatedObject(self, &UIP_SETTINGS_KEY, settings, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (NSDictionary *)settings
+{
+ return objc_getAssociatedObject(self, &UIP_SETTINGS_KEY);
+}
+
+@end