Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PrintColumnBleWriteDelegate.m 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // PrintColumnBleWriteDelegate.m
  3. // RNBluetoothEscposPrinter
  4. //
  5. // Created by januslo on 2018/10/6.
  6. // Copyright © 2018年 Facebook. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "PrintColumnBleWriteDelegate.h"
  10. @implementation PrintColumnBleWriteDelegate
  11. NSMutableArray<NSMutableString *> *columns;
  12. NSInteger maxRowCount;
  13. - (void)didWriteDataToBle:(BOOL)success {NSLog(@"Call back deletgate: %lu",_now+1);
  14. if(_canceled){
  15. if(_pendingReject) _pendingReject(@"ERROR_IN_PRINT_COLUMN",@"ERROR_IN_PRINT_COLUMN",nil);
  16. return;
  17. }
  18. _now = _now+1;
  19. if(_now >= maxRowCount){
  20. if(_error && _pendingReject){
  21. _pendingReject(@"ERROR_IN_PRINT_COLUMN",@"ERROR_IN_PRINT_COLUMN",nil);
  22. }else if(_pendingResolve){
  23. _pendingResolve(nil);
  24. }
  25. }else{
  26. if(!success){
  27. _error = true;
  28. }
  29. [self print];
  30. }
  31. [NSThread sleepForTimeInterval:0.05f];//slow down.
  32. }
  33. -(void)printColumn:( NSMutableArray<NSMutableString *> *)columnsToPrint withMaxcount:(NSInteger)maxcount{
  34. columns = columnsToPrint;
  35. maxRowCount = maxcount;
  36. [self print];
  37. }
  38. -(void)print{
  39. [(NSMutableString *)[columns objectAtIndex:_now] appendString:@"\n\r"];//wrap line..
  40. @try {
  41. [self.printer textPrint:[columns objectAtIndex:_now] inEncoding:_encodig withCodePage:_codePage widthTimes:_widthTimes heightTimes:_heightTimes fontType:_fontType delegate:self];
  42. }
  43. @catch (NSException *e){
  44. NSLog(@"ERROR IN PRINTING COLUMN:%@",e);
  45. _pendingReject(@"ERROR_IN_PRINT_COLUMN",@"ERROR_IN_PRINT_COLUMN",nil);
  46. self.canceled = true;
  47. }
  48. }
  49. @end;