Это фрагмент кода
-(IBAction)btnPrintClicked:(id)sender
{
[self performSelector:@selector(setupPrinting) withObject:nil afterDelay:0.3];
}
-(void)setupPrinting
{
AppAppDelegate *appDelegate=(AppAppDelegate *)[[UIApplication sharedApplication]delegate];
if([arrSelPrinters count]>0){
if([[[arrSelPrinters objectAtIndex:0] objectForKey:@"Type"] isEqualToString:@"Bluetooth"])
{
[self BluetoothPrintingg:0];
}
else
{
for(int p=0;p<[arrSelPrinters count];p++)
{
[self starPrinting:p];
}
}
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Printer not selected" message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[activityIndicator stopAnimating];
return;
}
-(void)starPrinting:(int *)pd
{
AppAppDelegate *appDelegate=(AppAppDelegate *)[[UIApplication sharedApplication]delegate];
SelPrintertag = pd;
NSString *strCustomerName=@"";
NSString *strRestaurantName=@"";
NSString *strcustomerph=@"";
NSString *orderdeliverydate=@"";
if ([[self.OrderDetailsbygenId objectForKey:@"EntityType"] isEqualToString:@"PickUp"])
{
NSArray *date1=[[self.OrderDetailsbygenId objectForKey:@"Time"] componentsSeparatedByString:@": "];
NSString *d1=[date1 objectAtIndex:0];
NSArray *date2=[[self.OrderDetailsbygenId objectForKey:@"DeliveryDate"]componentsSeparatedByString:@"T"];
NSString *d2=[date2 objectAtIndex:0];
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd"];
NSDate *date11 = [dateFormatter1 dateFromString: d2];
dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter1 setDateFormat:@"MM/dd/yy"];
NSString *convertedString1 = [dateFormatter1 stringFromDate:date11];
orderdeliverydate = [NSString stringWithFormat:@"%@ %@",convertedString1,d1];
}
else
{
NSArray *date1=[[self.OrderDetailsbygenId objectForKey:@"Time"] componentsSeparatedByString:@": "];
NSString *d1=[date1 objectAtIndex:0];
NSArray *date2=[[self.OrderDetailsbygenId objectForKey:@"DeliveryDate"]componentsSeparatedByString:@"T"];
NSString *d2=[date2 objectAtIndex:0];
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd"];
NSDate *date11 = [dateFormatter1 dateFromString: d2];
dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"en_US_POSIX"]];
[dateFormatter1 setDateFormat:@"MM/dd/yy"];
NSString *convertedString1 = [dateFormatter1 stringFromDate:date11];
orderdeliverydate = [NSString stringWithFormat:@"%@ %@",convertedString1,d1];
}
if([[self.OrderDetailsbygenId objectForKey:@"FirstName"]length]>0)
strCustomerName=[self.OrderDetailsbygenId objectForKey:@"FirstName"];
if([[self.OrderDetailsbygenId objectForKey:@"LastName"]length]>0 && !([[self.OrderDetailsbygenId objectForKey:@"LastName"] rangeOfString:@"null"].location != NSNotFound))
strCustomerName=[strCustomerName stringByAppendingString:[NSString stringWithFormat:@" %@",[self.OrderDetailsbygenId objectForKey:@"LastName"]]];
strCustomerName=strCustomerName;
strRestaurantName=[NSString stringWithFormat:@"%@ - %@",[self.OrderDetailsbygenId objectForKey:@"AppName"],[self.OrderDetailsbygenId objectForKey:@"LocationName"]];
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd/MM/YY hh:mm a"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
NSLog(@"%@",dateString);
NSString *strdelFee=@"";
NSString *strttip=@"";
if([[self.OrderDetailsbygenId objectForKey:@"DeliveryFee"] length]>0)
{
float del=0;
del=[[self.OrderDetailsbygenId objectForKey:@"DeliveryFee"] floatValue];
strdelFee=[NSString stringWithFormat:@"%@%0.02f",self.CurrencySign,del];
}
else
{
strdelFee= [NSString stringWithFormat:@"%@0.00",self.CurrencySign];
}
if([[self.OrderDetailsbygenId objectForKey:@"OrderTip"] length]>0)
{
float tip=0;
tip=[[self.OrderDetailsbygenId objectForKey:@"OrderTip"] floatValue];
strttip=[NSString stringWithFormat:@"%@%0.02f",self.CurrencySign,tip];
}
else
{
strttip=[NSString stringWithFormat:@"%@0.00",self.CurrencySign];
}
ModelIndex modelIndex = [ModelCapability modelIndexAtModelName:[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"ModelName"]];
if (modelIndex == ModelIndexTSP100)
{
if( [[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"Receipt"] isEqualToString:@"true" ] )
{
_strprint=@"No";
[self _starprintbody];
}
else if([[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"Kitchen"]isEqualToString:@"true" ]){
_strprint=@"Yes";
[self _starprintbody3];
}
else
{
_strprint=@"No";
[self _starprintbody];
}
}
else
{
[AppAppDelegate setSelectedPaperSize:PaperSizeIndexEscPosThreeInch];
[AppAppDelegate setSelectedLanguage:0]; // Same!!!
NSLog(@"%ld",[[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"EmulationValue"] integerValue]);
long error_code = [[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"EmulationValue"] integerValue];
ISCBBuilder *builder = [StarIoExt createCommandBuilder:
error_code];
// ISCBBuilder *builder = [StarIoExt createCommandBuilder: [AppAppDelegate getEmulation]];
[builder beginDocument];
if( [[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"Receipt"] isEqualToString:@"true" ] )
{
[builder appendDataWithAlignment:[[NSString stringWithFormat:@"**************Receipt Print**************\n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionCenter];
[builder appendDataWithAlignment:[[NSString stringWithFormat:@" \n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionCenter];
NSData *strorderId = [[NSString stringWithFormat:@"OrderId: %@\n",[self.drrOrderDet objectForKey:@"GenerateId"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strorderId position:SCBAlignmentPositionLeft];
NSData *strOrderType = [[NSString stringWithFormat:@"Order Type: %@\n",[self.drrOrderDet objectForKey:@"EntityType"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strOrderType position:SCBAlignmentPositionLeft];
NSData *AdvancedLabel = [[NSString stringWithFormat:@" %@\n",[self.OrderDetailsbygenId objectForKey:@"AdvancedLabel"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:AdvancedLabel position:SCBAlignmentPositionLeft];
NSData *strRestaurant = [[NSString stringWithFormat:@"Restaurant: %@\n",strRestaurantName] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strRestaurant position:SCBAlignmentPositionLeft];
NSData *strDateTime = [[NSString stringWithFormat:@"Order Date & Time: %@\n",dateString] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strDateTime position:SCBAlignmentPositionLeft];
// NSDictionary *attrs = @{ NSForegroundColorAttributeName : color };
// NSAttributedString *attrStr = [[NSAttributedString alloc] initWithString:[self.OrderDetailsbygenId objectForKey:@"PrepareBy"] attributes:attrs];
NSData *strprepareby = [[NSString stringWithFormat:@"%@\n",[self.OrderDetailsbygenId objectForKey:@"PrepareBy"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strprepareby position:SCBAlignmentPositionLeft];
NSData *strCustomer = [[NSString stringWithFormat:@"Customer: %@\n",strCustomerName] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strCustomer position:SCBAlignmentPositionLeft];
if ([[self.OrderDetailsbygenId objectForKey:@"EntityType"] isEqualToString:@"PickUp"]) {
NSData *strDeliveryDate = [[NSString stringWithFormat:@"PickUp Date & Time: %@\n",orderdeliverydate] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strDeliveryDate position:SCBAlignmentPositionLeft];
}
else
{
NSData *strDeliveryDate = [[NSString stringWithFormat:@"Delivery Date & Time: %@\n",orderdeliverydate] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strDeliveryDate position:SCBAlignmentPositionLeft];
}
if([[self.OrderDetailsbygenId objectForKey:@"PhoneNumber"] length]>0)
{
strcustomerph=[self.OrderDetailsbygenId objectForKey:@"PhoneNumber"];
NSData *strphono = [[NSString stringWithFormat:@"Ph#:%@\n",strcustomerph] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strphono position:SCBAlignmentPositionLeft];
}
NSData *strOrderedFrom = [[NSString stringWithFormat:@"Order From:%@\n",[self.OrderDetailsbygenId objectForKey:@"Platforms"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strOrderedFrom position:SCBAlignmentPositionLeft];
NSString *strPayment=@"";
if([[self.OrderDetailsbygenId objectForKey:@"PaymentMode"]isEqualToString:@"Cash"])
{
strPayment=@"*Not Paid collect Payment*";
}
else
{
strPayment=@"Payment received do not charge";
}
NSData *strPaymentMode = [[NSString stringWithFormat:@"%@\n",strPayment] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strPaymentMode position:SCBAlignmentPositionLeft];
[builder appendUnderLine:YES];
[builder appendDataWithAlignment:[[NSString stringWithFormat:@" \n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionLeft];
[builder appendUnderLine:NO];
for(int i=0;i<[Itemsarray count];i++)
{
NSMutableDictionary *d =[[NSMutableDictionary alloc]initWithDictionary: [[Itemsarray objectAtIndex:i] lastObject]];
NSMutableArray *choicesarray;
choicesarray=[[NSMutableArray alloc]initWithArray:[[Itemsarray objectAtIndex:i] objectAtIndex:0]];
NSString *choicename=@"";
strcheckforprint=nil;
NSString *finalchoicecontent=@"";
NSString *itemPrice=@"";
for (int i=0;i<[choicesarray count];i++)
{
if([[[choicesarray objectAtIndex:i] objectForKey:@"OptionName"] length]>0)
{
if(i==0)
choicename=[choicename stringByAppendingString:[NSString stringWithFormat:@"%@:",[[choicesarray objectAtIndex:i] objectForKey:@"OptionName"]]];
else
choicename=[choicename stringByAppendingString:[NSString stringWithFormat:@",%@:",[[choicesarray objectAtIndex:i] objectForKey:@"OptionName"]]];
}
if([[[choicesarray objectAtIndex:i] objectForKey:@"ChoiceName"] length]>0)
{
NSString *h=[NSString stringWithFormat:@" / %@",[[choicesarray objectAtIndex:i] objectForKey:@"ChoiceName"]];
choicename=[choicename stringByAppendingString:h];
}
}
if([choicesarray count]>0)
{
NSString *newStr;
newStr=[choicename stringByReplacingOccurrencesOfString:@": /" withString:@":"];
finalchoicecontent=newStr;
}
itemPrice=[NSString stringWithFormat:@"%@%@",self.CurrencySign,[d valueForKey:@"Price"]];
NSString *s1;
}
}
[builder appendUnderLine:YES];
[builder appendDataWithAlignment:[[NSString stringWithFormat:@" \n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionLeft];
[builder appendUnderLine:NO];
NSData *strTipPrice = [[NSString stringWithFormat:@"%@\n",strttip] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strTipPrice position:SCBAlignmentPositionRight];
NSData *strDeliFee = [[NSString stringWithFormat:@"DeliveryFee: "] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strDeliFee position:SCBAlignmentPositionLeft];
NSData *strDeliFeePrice = [[NSString stringWithFormat:@"%@\n",strdelFee] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strDeliFeePrice position:SCBAlignmentPositionRight];
NSString *strmainTotal= [NSString stringWithFormat:@"%@%@",self.CurrencySign,[formatter stringFromNumber:[NSNumber numberWithFloat:[[[self.OrderDetailsbygenId objectForKey:@"TotalPrice"]stringByReplacingOccurrencesOfString:@"," withString:@"" ]floatValue]]]];
NSData *strTotal = [[NSString stringWithFormat:@"Total: "] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strTotal position:SCBAlignmentPositionLeft];
NSData *strTotalPrice = [[NSString stringWithFormat:@"%@\n",strmainTotal] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strTotalPrice position:SCBAlignmentPositionRight];
if (![[self.OrderDetailsbygenId objectForKey:@"EntityType"] isEqualToString:@"PickUp"]) {
NSString *strDeiveryAddress=@"Delivery Address:\n";
if([[self.OrderDetailsbygenId objectForKey:@"Line1"]length]>0)
{
NSString *str=[NSString stringWithFormat:@"%@",[self.OrderDetailsbygenId objectForKey:@"Line1"]];
strDeiveryAddress=[strDeiveryAddress stringByAppendingString:str];
}
[builder appendUnderLine:YES];
[builder appendDataWithAlignment:[[NSString stringWithFormat:@" \n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionLeft];
[builder appendUnderLine:NO];
if([[self.OrderDetailsbygenId objectForKey:@"Note"]length]>0)
{
UIColor *color = [UIColor redColor]; // select needed color
// NSDictionary *attrs = @{ NSForegroundColorAttributeName : color };
// NSAttributedString *attrStr1 = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"Order Instructions: %@\n",[self.OrderDetailsbygenId objectForKey:@"Note"]] attributes:attrs];
NSData *strInstruction = [[NSString stringWithFormat:@"Order Instructions: %@\n",[self.OrderDetailsbygenId objectForKey:@"Note"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strInstruction position:SCBAlignmentPositionLeft];
}
[builder appendDataWithAlignment:[[NSString stringWithFormat:@"\n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionCenter];
NSData *strorderId = [[NSString stringWithFormat:@"OrderId: %@\n",[self.drrOrderDet objectForKey:@"GenerateId"]] dataUsingEncoding:NSUTF8StringEncoding];
[builder appendDataWithAlignment:strorderId position:SCBAlignmentPositionLeft];
[builder appendDataWithAlignment:[[NSString stringWithFormat:@"\n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionCenter];
[builder appendDataWithAlignment:[[NSString stringWithFormat:@"******************************************\n"] dataUsingEncoding:NSUTF8StringEncoding] position:SCBAlignmentPositionCenter];
}
[builder appendCutPaper:SCBCutPaperActionPartialCutWithFeed];
[builder endDocument];
NSData *commands = nil;
commands = [builder.commands copy];
NSString *portName = [[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"PortName"];
NSString *portSettings = [[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"PortSettings"];
[Communication sendCommands:commands
portName:portName
portSettings:portSettings
timeout:10000
completionHandler:^(BOOL result, NSString *title, NSString *message) {
// dispatch_async(GlobalQueueManager.sharedManager.serialQueue, ^{
// dispatch_async(dispatch_get_main_queue(), ^{
if ([message isEqualToString:@"Success"])
{
//
[alertPrinting dismissWithClickedButtonIndex:0 animated:YES];
if (strAlertdismiss) {
strAlertdismiss=false;
NSString*strmsg = [NSString stringWithFormat:@"Successfully printed Order %@",[self.drrOrderDet objectForKey:@"GenerateId"]];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:strmsg message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
[activityIndicator stopAnimating];
}
else
{
[alertPrinting dismissWithClickedButtonIndex:0 animated:YES];
if (strSP700Fail) {
strSP700Fail=false;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Printing failed"
message:[NSString stringWithFormat: @"Please check %@ printer's connection and ensure that it has enough paper.",[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"ModelName"]]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
if (strmCPFail) {
strmCPFail=false;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Printing failed"
message:[NSString stringWithFormat: @"Please check %@ printer's connection and ensure that it has enough paper.",[[arrSelPrinters objectAtIndex:SelPrintertag]objectForKey:@"ModelName"]]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
[activityIndicator stopAnimating];
}
[arrSelPrinters removeObjectAtIndex:SelPrintertag];
if(arrSelPrinters.count>0)
[self setupPrinting];
}];
}
Может кто-нибудь, пожалуйста, подскажет, что говорит ошибка doesNotRecogniseSelector и как ее устранить.