Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to reconnect to EAAccessory in iOS?
I am using ExternalAccessory framework in iOS. The first connection works fine:
session = [[EASession alloc] initWithAccessory:self.accessory
forProtocol:@"com.domain.protocol"];
[[session inputStream] setDelegate:self];
[[session inputStream] scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[[session inputStream] open];
[[session outputStream] setDelegate:self];
[[session outputStream] scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[[session outputStream] open];
[[session inputStream] read:buf2 maxLength:1024];
[[session inputStream] setDelegate:nil];
[[session inputStream] removeFromRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[[session inputStream] close];
//
[[session outputStream] setDelegate:nil];
[[session outputStream] removeFromRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[[session outputStream] close];
ERROR - opening session failed
Answer the question
In order to leave comments, you need to log in
Well, I don’t know how correctly I understood what you wrote, but you:
firstly, you don’t create, but simply allocate memory for this object and initialize it,
and secondly, how do you create a new session? Do you just need to open the stream? Do simply [[session inputStream] open];
Where in general repeated attempt "to create new session"? If you just run all this code over again, then it will not work, because it allocates memory for an object that is already in memory. take out
session = [[EASession alloc] initWithAccessory:self.accessory
forProtocol:@"com.domain.protocol"];
[[session inputStream] setDelegate:self];
[[session inputStream] scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question