Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 调用方法导致创建LLDB目标时出错_Ios_Objective C - Fatal编程技术网

Ios 调用方法导致创建LLDB目标时出错

Ios 调用方法导致创建LLDB目标时出错,ios,objective-c,Ios,Objective C,我正在尝试制作我的第一个Objective-C库。我正在创建一个方法,它将接收UIImage并返回NSMutableData。我创建了以下内容: + (NSMutableData *)GetDataToSendToPrinter:(UIImage *)image { int maxWidth = 100; BOOL drawerKick = YES; BOOL compressionEnable = YES; RasterDocument *rasterDoc

我正在尝试制作我的第一个Objective-C库。我正在创建一个方法,它将接收UIImage并返回NSMutableData。我创建了以下内容:

+ (NSMutableData *)GetDataToSendToPrinter:(UIImage *)image
{

    int maxWidth = 100;
    BOOL drawerKick = YES;
    BOOL compressionEnable = YES;

    RasterDocument *rasterDoc = [[RasterDocument alloc] initWithDefaults:RasSpeed_Medium endOfPageBehaviour:RasPageEndMode_FeedAndFullCut endOfDocumentBahaviour:RasPageEndMode_FeedAndFullCut topMargin:RasTopMargin_Standard pageLength:0 leftMargin:0 rightMargin:0];
    StarBitmap *starbitmap = [[StarBitmap alloc] initWithUIImage:image :maxWidth :false];

    NSMutableData *commandsToPrint = [[NSMutableData alloc] init];
    NSData *shortcommand = [rasterDoc BeginDocumentCommandData];
    [commandsToPrint appendData:shortcommand];

    shortcommand = [starbitmap getImageDataForPrinting:compressionEnable];
    [commandsToPrint appendData:shortcommand];

    shortcommand = [rasterDoc EndDocumentCommandData];
    [commandsToPrint appendData:shortcommand];

    if (drawerKick == YES) {
        [commandsToPrint appendBytes:"\x07"
                              length:sizeof("\x07") - 1];    // KickCashDrawer
    }

    [starbitmap release];
    [rasterDoc release];

    return commandsToPrint;

}
仅出于测试目的,我尝试从按钮单击事件调用它:

- (IBAction)DevButton_TouchUpInside:(id)sender {


    UIImage *imageToPrint = [UIImage imageNamed:@"image1.png"];

//    NSMutableData *commandsToPrint = [[NSMutableData alloc] init];
//    *commandsToPrint=[self GetDataToSendToPrinter:imageToPrint];

    //This is where I call it
    NSMutableData *commandsToPrint = [self GetDataToSendToPrinter:imageToPrint]; 

    int commandSize = (int)[commandsToPrint length];
    unsigned char *dataToSentToPrinter = (unsigned char *)malloc(commandSize);
    [commandsToPrint getBytes:dataToSentToPrinter];

    NSString *portName = @"TCP:10.0.1.4";
    NSString *portSettings = @"Standard";
    NSMutableString *message;

    SMPort *starPort = nil;
    starPort = [SMPort getPort:portName :portSettings :10000];
    [starPort writePort:dataToSentToPrinter :0 :commandSize];
}
但是,当单击按钮时,我不断遇到以下崩溃:

Warning: Error creating LLDB target at path '/Users/.../Library/Developer/Xcode/DerivedData/IOS_SDK-cjctcqoxudpegpadjbwitveqtkso/Build/Products/Debug-iphonesimulator/StarIO SDK.app'- using an empty LLDB target which can cause slow memory reads from remote devices.
2014-09-26 18:39:22.588 StarIO SDK[17823:513276] -[IOS_SDKViewControllerRasterMode GetDataToSendToPrinter:]: unrecognized selector sent to instance 0xb366260
2014-09-26 18:39:22.624 StarIO SDK[17823:513276] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[IOS_SDKViewControllerRasterMode GetDataToSendToPrinter:]: unrecognized selector sent to instance 0xb366260'
*** First throw call stack:
(
    0   CoreFoundation                      0x021c4df6 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x01c49a97 objc_exception_throw + 44
    2   CoreFoundation                      0x021cca75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
    3   CoreFoundation                      0x021159c7 ___forwarding___ + 1047
    4   CoreFoundation                      0x0211558e _CF_forwarding_prep_0 + 14
    5   StarIO SDK                          0x000428bb -[IOS_SDKViewControllerRasterMode DevButton_TouchUpInside:] + 107
    6   libobjc.A.dylib                     0x01c5f7cd -[NSObject performSelector:withObject:withObject:] + 84
    7   UIKit                               0x0042179d -[UIApplication sendAction:to:from:forEvent:] + 99
    8   UIKit                               0x0042172f -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
    9   UIKit                               0x00554a16 -[UIControl sendAction:to:forEvent:] + 69
    10  UIKit                               0x00554e33 -[UIControl _sendActionsForEvents:withEvent:] + 598
    11  UIKit                               0x0055409d -[UIControl touchesEnded:withEvent:] + 660
    12  UIKit                               0x00471aba -[UIWindow _sendTouchesForEvent:] + 874
    13  UIKit                               0x00472595 -[UIWindow sendEvent:] + 791
    14  UIKit                               0x00437aa9 -[UIApplication sendEvent:] + 242
    15  UIKit                               0x004478de _UIApplicationHandleEventFromQueueEvent + 20690
    16  UIKit                               0x0041c079 _UIApplicationHandleEventQueue + 2206
    17  CoreFoundation                      0x020e87bf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    18  CoreFoundation                      0x020de2cd __CFRunLoopDoSources0 + 253
    19  CoreFoundation                      0x020dd828 __CFRunLoopRun + 952
    20  CoreFoundation                      0x020dd1ab CFRunLoopRunSpecific + 443
    21  CoreFoundation                      0x020dcfdb CFRunLoopRunInMode + 123
    22  GraphicsServices                    0x03b8c24f GSEventRunModal + 192
    23  GraphicsServices                    0x03b8c08c GSEventRun + 104
    24  UIKit                               0x0041fe16 UIApplicationMain + 1526
    25  StarIO SDK                          0x000027e2 main + 130
    26  libdyld.dylib                       0x036f0ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我觉得我错过了一些基本的东西。这是我创建的第一个Objective-C方法,我只是想构建一个简单的库,然后用Xamarin绑定封装。哪里出错了?

您正在从实例方法调用类方法

+ (NSMutableData *)GetDataToSendToPrinter:(UIImage *)image //Should be called using the class name
- (IBAction)DevButton_TouchUpInside:(id)sender //Should be called using self
我不确定它是如何编译的,你应该得到这样一个错误:

IOS的@interface\u SDKViewControllerRasterMode没有可见的声明选择器“GetDataToSendToPrinter:”

根据它吐出的日志,它找不到函数GetDataToSendToPrinter:。尝试将其作为类方法调用:

NSMutableData *commandsToPrint = [IOS_SDKViewControllerRasterMode GetDataToSendToPrinter:imageToPrint];