I have a method which need receive a Byte[]
:
In the .h
file:
- (void)setPC1_APPKEY:(Byte[] )pC1_APPKEY;
In the .m
file:
I want to own a Byte[]
property to save it.
But when I declare the property like this:
@property (nonatomic, assign) Byte PC1_APPKEY[];
It shows error: property cannot have array or function type'Byte[]'
And so I set it to attribute like this:
{
Byte PC1_APPKEY[];
}
It shows error: Field has Incomplete type 'Byte[]'
How can I get the Byte[]
? thanks.
you can use Pointer like this
@property (nonatomic, assign) Byte *PC1_APPKEY;
all files
.h
//
// ocViewController.h
// testTableViewHeader
//
// Created by 刷脸卡 on 10/11/16.
// Copyright © 2016 曾祥林. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TestViewController : UIViewController
- (void)setPC1_APPKEY:(Byte[] )pC1_APPKEY;
@end
.m
//
// ocViewController.m
// testTableViewHeader
//
// Created by 刷脸卡 on 10/11/16.
// Copyright © 2016 曾祥林. All rights reserved.
//
#import "TestViewController.h"
@interface TestViewController ()
@property (nonatomic, assign) Byte *PC1_APPKEY;
@end
@implementation TestViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *testString = @"1234567890";
NSData *testData = [testString dataUsingEncoding: NSUTF8StringEncoding];
self.PC1_APPKEY = (Byte *)[testData bytes];
for(int i=0;i<[testData length];i++){
printf("testByte = %d\n",self.PC1_APPKEY[i]);
}
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)setPC1_APPKEY:(Byte [])pC1_APPKEY{
self.PC1_APPKEY = pC1_APPKEY;
}
@end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.