Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

codenameone - Can an iOS native interface use NSData (byte[]) as a parameter or return value?

Edit: As per the answer below, the answer is YES, it can

I tried looking through the docs but didn't find any reference to this

I tried building but there always is an error whenever the return value or a param in a native interface is NSData (byte[])

Is it not supported? Thx

For example, the following interfaces blow:

- (NSData*)someMethod{
}

- (void)someMethod:(NSData*)param{
}

The server error file never mentions any specific error when an error occurs in a native interface class so I am asking here for clarity/reference

question from:https://stackoverflow.com/questions/65598329/can-an-ios-native-interface-use-nsdata-byte-as-a-parameter-or-return-value

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm not sure about the return value but the parameter should work and is documented in Listing 22. NativeInterface definition in the developer guide as:

public void test(byte b, boolean boo, char c, short s,
    int i, long l, float f, double d, String ss,
    byte[] ba, boolean[] booa, char[] ca, short[] sa, int[] ia,
    long[] la, float[] fa, double[] da,
    PeerComponent cmp);

Which generates:

-(void)test:(char)param param1:(BOOL)param1
    param2:(int)param2 param3:(short)param3 param4:(int)param4
    param5:(long long)param5 param6:(float)param6
    param7:(double)param7 param8:(NSString*)param8
    param9:(NSData*)param9 param10:(NSData*)param10
    param11:(NSData*)param11 param12:(NSData*)param12
    param13:(NSData*)param13 param14:(NSData*)param14
    param15:(NSData*)param15 param16:(NSData*)param16
    param17:(void*)param17;
}

If you're getting an error we'll need the link for the full error log as well as the applicable native interface code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...