Zebra imz320 zpl蓝牙打印机“ZSDK_API_ERROR_DOMAIN” - 代码:1错误

时间:2016-01-27 09:36:12

标签: ios objective-c bluetooth zpl zebra

我正在尝试使用Zebra iMZ320打印机在我的iOS应用程序上进行扩展。我跟随斑马的开发者指南。但是有关于SDK的错误。

这是我的代码:

- (IBAction)buttonPressed:(id)sender {
NSString *serialNumber = @"";
//Find the Zebra Bluetooth Accessory
EAAccessoryManager *sam = [EAAccessoryManager sharedAccessoryManager];
NSArray * connectedAccessories = [sam connectedAccessories];
for (EAAccessory *accessory in connectedAccessories) {
    if([accessory.protocolStrings indexOfObject:@"com.zebra.rawport"] != NSNotFound){
        serialNumber = accessory.serialNumber;
        break;
        //Note: This will find the first printer connected! If you have multiple Zebra printers connected, you should display a list to the user and have him select the one they wish to use
    }
}
// Instantiate connection to Zebra Bluetooth accessory
id<ZebraPrinterConnection, NSObject> thePrinterConn = [[MfiBtPrinterConnection alloc] initWithSerialNumber:serialNumber];

// Open the connection - physical connection is established here.
BOOL success = [thePrinterConn open];

// This example prints "This is a ZPL test." near the top of the label.
NSString *zplData = @"^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

NSError *error = nil;
// Send the data to printer as a byte array.
success = success && [thePrinterConn write:[zplData dataUsingEncoding:NSUTF8StringEncoding] error:&error];

if (success != YES || error != nil) {
    UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [errorAlert show];
}

}

然而,当我尝试打印时,我从上一个NSError变量收到错误。它处于写入功能。

domain: "ZSDK_API_ERROR_DOMAIN" - code: 1

有人可以帮忙吗?提前谢谢。

1 个答案:

答案 0 :(得分:-1)

尝试使用zebra-toolkit。管理打印机和使用ZPL可以省去很多麻烦。

相关问题