how to use NSCoder for transfer images and strings together over bluetooth?
I want to use NSCoder and transfer NSString and UIImage with single NSData over bluetooth
you can simply say, "I want to sent NSData over bluetooth which contains UIImage and NSString"
Help me out,,,
It is very complex question, and I am 开发者_运维问答stuck here since two days :-(
Create a objective-c class with propertys NSString and UIImage
Than you need to implement
-(void) encodeWithCoder: (NSCoder *) encoder
{
[super encodeWithCoder:encoder];
[encoder encodeObject: [self yourString] forKey:@"string"];
[encoder encodeObject: [self yourImage] forKey:@"image"];
}
-(id) initWithCoder: (NSCoder *) decoder
{
[super initWithCoder:decoder];
self.yourString = [decoder decodeObjectForKey:@"string"];
self.yourImage = [decoder decodeObjectForKey:@"image"];
return self;
}
now the problem is, that UIImage doesn't implement encodeWithCoder the solution can you find here: Archiving UIImages with NSCoder
精彩评论