FCNDEFMessage queryNDEFStatusWithCompletionHandler:]: unrecognized selector sent to instance - ios

I'm trying to obtain some information about a NFC tag, the session is successfully started and after reading a tag, we jump into the following function:
- (void) readerSession:(NFCNDEFReaderSession *)session didDetectNDEFs:(NSArray<NSObject<NFCNDEFTag> * > *)tags {
NSLog(#"NFCNDEFReaderSession didDetectNDEFs");
for (NSObject<NFCNDEFTag> *tag in tags) {
[tag queryNDEFStatusWithCompletionHandler:^(NFCNDEFStatus status, NSUInteger capacity, NSError * _Nullable error) {
if (!error) {
NSLog(#"success");
}
}];
}
}
We even get an iteration in the loop, but in the moment I try to obtain some information about my tag, the app crashes with the following error message:
019-11-06 16:01:12.955810+0100 MyApp[336:10691] -[NFCNDEFMessage queryNDEFStatusWithCompletionHandler:]: unrecognized selector sent to instance 0x281cfce30
2019-11-06 16:01:12.956200+0100 MyApp[336:10691] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NFCNDEFMessage queryNDEFStatusWithCompletionHandler:]: unrecognized selector sent to instance 0x281cfce30'
*** First throw call stack:
(0x18e45180c 0x18e179fa4 0x18e35536c 0x18e455c88 0x18e457a6c 0x100636cc0 0x100b097fc 0x100b0abd8 0x100b11b48 0x100b12718 0x100b1dadc 0x18e16ef88 0x18e171ad4)
libc++abi.dylib: terminating with uncaught exception of type NSException
Note: NFCNDEFTag is a protocol, so maybe it's connected with the way I'm declaring it: NSObject<NFCNDEFTag>?

Let's see the doc of NFCNDEFReaderSessionDelegate.
You have:
- (void)readerSession:(NFCNDEFReaderSession *)session
didDetectNDEFs:(NSArray<NFCNDEFMessage *> *)messages;
and
- (void)readerSession:(NFCNDEFReaderSession *)session
didDetectTags:(NSArray<__kindof id<NFCNDEFTag>> *)tags;
You wrote:
- (void)readerSession:(NFCNDEFReaderSession *)session
didDetectNDEFs:(NSArray<NSObject<NFCNDEFTag> * > *)tags {
Which is a mix of the two.
But in Objective-C, the selector will be:
readerSession:didDetectNDEFs & readerSession:didDetectTags: for the official one, and yours is readerSession:didDetectNDEFs, which is the same as the first one. So you lured the compiler and the runtime for yours.
But it doesn't care of the type of the parameters, so it's not the correct object, so it doesn't implement the method queryNDEFStatusWithCompletionHandler:, so it crashes with that error message.
How to fix it?
Implement the real delegate methods, with the good parameters types, use the correct one, you can't modify them like that as you want.

Related

Azure Communication Calling SDK crashes on start call

I am trying to start a one on one call using Azure CommunicationCalling sdk. I am getting a crash inside one of the sdk functions as shown in screenshot for backtrace below.
Code for start call:-
func startCall(callee: String, successHandler: #escaping (Call?) -> Void ) {
// start call logic
debugPrint(callee)
let callees:[CommunicationIdentifier] = [createCommunicationIdentifier(fromRawId: callee)]
debugPrint(callees)
self.callAgent?.startCall(participants: callees, options: StartCallOptions()) { (call, error) in
if let error = error {
debugPrint(error.localizedDescription)
successHandler(nil)
} else {
self.call = call
debugPrint("call placed successfully")
successHandler(call)
}
}
}
I have verified that call agent and communication identifier arr obj passed is not nil.
Crash log:-
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
terminating with uncaught exception of type NSException
BackTrace for crash:-
I have referred to following documentation:-
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/ui-library/get-started-composites?tabs=kotlin&pivots=platform-ios
This crash doesnt happen anymore with same sdk version. Also the beta sdk version (v2.3.0-beta.2) is working fine too.

Objective-c Completion handler to Delphi

In Objective-c header I have this :
- (void)offerForConstraints:(RTCMediaConstraints *)constraints
completionHandler:(nullable void (^)(RTCSessionDescription *_Nullable sdp,
NSError *_Nullable error))completionHandler;
That I translate like this:
type
TWebRTCPeerConnectionOfferForConstraintsCompletionHandler =
procedure(sdp: RTCSessionDescription; error: NSError) of object;
procedure offerForConstraints(
constraints: RTCMediaConstraints;
completionHandler: TWebRTCPeerConnectionOfferForConstraintsCompletionHandler); cdecl;
But every time I call offerForConstraints I Have :
Access violation at address 0000000183398910, accessing address
000000004D555468 At address: $0000000183398910 (objc_msgSend + 16)
sometimes I also have this error:
-[__NSCFDictionary offerForConstraints:completionHandler:]: unrecognized selector sent to instance 0x1c0271b40
or this one:
-[_CFXNotificationObserverRegistration offerForConstraints:completionHandler:]: unrecognized selector sent to
instance 0x1c4273a40
Any idea what going wrong?

Having an error when fetching request of Core Data

I want to store some new data in core data. Most of the times it works, but it gives an error of
[error] error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. *** Collection <__NSCFSet: 0x16eb6a50> was mutated while being enumerated. with userInfo (null)
CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. *** Collection <__NSCFSet: 0x16eb6a50> was mutated while being enumerated. with userInfo (null)
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSCFSet: 0x16eb6a50> was mutated while being enumerated.'
*** First throw call stack:
(0x1deefb3d 0x1d177067 0x1deef5e1 0x1fea4bbb 0x1fe8a863 0x1fe89be5 0x1fe68da9 0x9403ec 0x8cefc 0x137ed0 0x134530 0x13790c 0x126ab0 0xd0be0 0xd3a467 0xd3a453 0xd3ed47 0x1deabd69 0x1dea9e19 0x1ddfd1af 0x1ddfcfd1 0x1f5a7b41 0x2317fa53 0x8e068 0x1d5ea4eb)
libc++abi.dylib: terminating with uncaught exception of type NSException
occasionally.
Here are the codes of getData in AppDelegate
func getData(request: NSFetchRequest<NSManagedObject>) -> Any{
do {
let context = persistentContainer.viewContext
let results = try context.fetch(request)
return results
} catch {
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
I discovered that it breaks at let results = try context.fetch(request). I wonder if there is any problem with this line or other lines?
Does anyone have any ideas? Thanks in advance

import AlgoliaSearch with Swift 2 causing error

Adding this line to my App import AlgoliaSearch returns this error:
2017-05-08 22:35:07.814593 XXXXXX[6255:2627487] -[__NSDictionaryI
length]: unrecognized selector sent to instance 0x1702f0980 2017-05-08
22:35:07.816565 XXXXXX[6255:2627487] * Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSDictionaryI length]: unrecognized selector sent to instance
0x1702f0980'
* First throw call stack: (0x192f351b8 0x19196c55c 0x192f3c268 0x192f39270 0x192e3280c 0x1015c8608 0x10158d72c 0x10194a198
0x1001f6c24 0x1001f8c9c 0x100091fd4 0x1003973d4 0x100397690
0x1003be2c0 0x101a5d258 0x101a5d218 0x101a62280 0x192ee2810
0x192ee03fc 0x192e0e2b8 0x1948c2198 0x198e557fc 0x198e50534
0x10013c734 0x191df15b8) libc++abi.dylib: terminating with uncaught
exception of type NSException (lldb)
The line of code it is referring to is as below:
self.ref.child("users").observeSingleEventOfType(.Value, withBlock: { (snapshot) in
for user in snapshot.children{
var numVids = NSDictionary()
if ((user.hasChild("videos")) == true){
--> numVids = user.value["videos"] as! NSDictionary
}
}
As soon as I remove the import Algolia module the error is removed, I have tried changing the version of the module and even switching to use the objc version but the error was the same.
Anyone seen something like this before?
https://github.com/algolia/algoliasearch-client-swift
https://github.com/algolia/algoliasearch-client-objc

CKModifyBadgeOperation crashes for no reason

I have created a subscription for insert & it sends push notification as follows
let subscriptionNotification = CKNotificationInfo()
subscriptionNotification.alertBody = "New Book has been created by Author"
subscriptionNotification.shouldBadge = true
subscription.notificationInfo = subscriptionNotification
When I receive the notification I open the app & I am simply trying to reset badge to zero
let resetBadge = CKModifyBadgeOperation(badgeValue: 0)
resetBadge.modifyBadgeCompletionBlock = {(error) in
if error != nil {
print(error)
}
else {
application.applicationIconBadgeNumber = 0
}
}
CKContainer.defaultContainer().addOperation(resetBadge)
I run this code on appdelegate did finish launching with options method.
I get following error. Keep in mind the name of the project is ckreference demo.
2015-12-15 21:41:58.417 ckreference demo[2486:1478837] -[CKNotification queryNotificationReason]: unrecognized selector sent to instance 0x15cd8a960
2015-12-15 21:41:58.427 ckreference demo[2486:1478837] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CKNotification queryNotificationReason]: unrecognized selector sent to instance 0x15cd8a960'
* First throw call stack:
(0x183521900 0x182b8ff80 0x18352861c 0x1835255b8 0x18342968c 0x1000b8b9c 0x1000b9250 0x1884cbae4 0x1884b9de0 0x184ad7790 0x184ad7b10 0x1834d8efc 0x1834d8990 0x1834d6690 0x183405680 0x184914088 0x18827cd90 0x1000b94d0 0x182fa68b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any suggestions on how to stop app from crashing?
The crash happens here

Resources