Question

I am using method called showBluetoothAccessoryPickerWithNameFilter:completion: which is a part of External accessory framework. It just returns bluetooth devices which iPhone found and you can pick one to connect to it.

If I use this arguments: showBluetoothAccessoryPickerWithNameFilter:nil completion:nil, it returns all devices but you can specify which devices it should returns with NSPredicate (Filter argument). So I tried to create predicate like this:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self CONTAINS MyString"];
[[EAAccessoryManager sharedAccessoryManager] showBluetoothAccessoryPickerWithNameFilter:predicate completion:nil]

But when I run the app, there is an error something like:

class is not key value coding-compliant for the key MyString.

I suppose that problem is with self word in predicate because in this case self means instance of current class. Am I right? How should I write a predicate if I want to get only devices that contain MyString in its name? Thank you guys.

Était-ce utile?

La solution

The EAAccessoryManager documentation says that the predicate is evaluated using the name of the accessory. Your problem is that you should put MyString between quotes:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self CONTAINS 'MyString'"];

Hope it helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top