I'm scratching my head over this one, I thought the whole point of checking for nil was to ensure unsafe variables were ignored at run-time allowing the app to not crash.
I have tried to check the key returned from the server for nil, and also tried optional chaining to test for nil, neither are working and I still get the error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Key "avatar" has no data. Call fetchIfNeeded before getting its value.'
I understand this means that no data was found for the avatar key, but due to the tests I am running I'm confused why this error is even being raised
for var i = 0; i < recipients.count; i++
{
if let u = recipients[i] as PFUser!
{
if u.valueForKey("avatar") != nil
{
println(i)
}
}
}
Conversely, I tried to optional chain the result of the image:
if let image: UIImage = UIImage(data: (u["avatar"]!.getData() as NSData?)!) {}
Both times the application will crash throwing the exception stated above. My stack trace shows nothing else which is of use, however the println statement will print 0, 1 and then crash on element 2 (where the collection size is 4 so I am not out of bounds).
Any ideas on how I can fix this?
Related
Currently getting the following runtime exception
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Animator <UIViewPropertyAnimator(0x600003f24200) [stopped] interruptible> is already stopped!'
Because of the following line of code
// other code up here that modifies offsetAnimator
...
// stop any current running animations on offset
if let offsetAnimator = offsetAnimator {
offsetAnimator.stopAnimation(false) // this line is where the exception gets raised
offsetAnimator.finishAnimation(at: .end)
}
What is perplexing, however, is why this error is NOT readily reproducible
// doing this doesn't always result in an error
if let offsetAnimator = offsetAnimator {
offsetAnimator.stopAnimation(false)
offsetAnimator.finishAnimation(at: .end)
offsetAnimator.stopAnimation(false)
offsetAnimator.finishAnimation(at: .end)
}
What on earth is happening? Can someone explain to me why this error is occurring?
Why does it seem to only happen sporadically? Shouldn't calling .stop twice always trigger it?
I keep getting this pesky error on init sometimes. It occurs for a while and sometimes it goes away. I am not sure what is the problem. Please help. Details below
Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
The stack trace points to this piece of init() code.
init() {
guard let AK52_input = AK52_engine.input else {
fatalError()
}
do {
AK52_recorder = try NodeRecorder(node: AK52_input)
} catch let err {
fatalError("\(err)")
}
let silencer = Fader(AK52_input, gain: 0)
self.AK52_silencer = silencer
AK52_mixer.addInput(silencer)
AK52_mixer.addInput(AK52_player)
AK52_engine.output = AK52_mixer <----- error pops from here
}
And this code is identical to the one in the AudioCookbook. Infact, I see the same error when I run AudioCookbook too.
Please help.
thanks,
-Vittal
I'm developing a Flutter app which makes use of the Digital Ink Recognition of ML Kit to recognize handwriting.
I have the following code to perform the recognition on iOS (swift code).
let ink = Ink.init(strokes: mlStrokes)
let identifier = DigitalInkRecognitionModelIdentifier(forLanguageTag: languageTag)
if identifier == nil {
flutterResult(FlutterError(code: "ERROR", message: "No model for language tag found or the language tag could not be parsed", details: nil))
}
let model = DigitalInkRecognitionModel.init(modelIdentifier: identifier!)
// Get a recognizer for the given language
let options: DigitalInkRecognizerOptions = DigitalInkRecognizerOptions.init(model: model)
digitalInkRecognizer = DigitalInkRecognizer.digitalInkRecognizer(options: options)
digitalInkRecognizer.recognize(
ink: ink,
completion: {
(result: DigitalInkRecognitionResult?, error: Error?) in
if let result = result {
var flutterCandidates : [[String: Any?]] = []
for candidate in result.candidates {
flutterCandidates.append(
["text" : candidate.text, "score" : candidate.score]
)
}
// Return recognised candidates to Flutter.
self.flutterResult(flutterCandidates)
} else {
self.flutterResult(FlutterError(code: "ERROR", message: "Unable to recognize handwriting", details: error))
}
})
I'm recognizing a single letter at a time.
This works well for some time, the correct letter is returned in the completion callback and then send back to my Flutter app, but after the method is called a few times (~20), the following error is thrown in the console and my app crashes.
I1025 10:03:01.607888 1 lstm_recognizer.cc:77] Loaded tflite model.
2021-10-25 10:03:01.621992+0200 Runner[796:125890] Unsupported value: Error Domain=com.google.mlkit Code=13 "Unable to initialize recognizer: generic::internal: Unable to mmap file descriptor (Cannot allocate memory). (research/handwriting/util/mmap_data.cc:49)" UserInfo={NSLocalizedDescription=Unable to initialize recognizer: generic::internal: Unable to mmap file descriptor (Cannot allocate memory). (research/handwriting/util/mmap_data.cc:49)} of type NSError
2021-10-25 10:03:01.623350+0200 Runner[796:125890] *** Assertion failure in -[FlutterStandardWriter writeValue:], FlutterStandardCodec.mm:334
2021-10-25 10:03:01.632824+0200 Runner[796:125890] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported value for standard codec'
*** First throw call stack:
(0x20ff2e180 0x20f1069f8 0x20fe4788c 0x21090bb38 0x1034b8138 0x1034b8898 0x1034b5890 0x100c4f0f4 0x100c522fc 0x100c523a8 0x1052536f4 0x105254c78 0x1052626fc 0x20febfb20 0x20febaa58 0x20feb9fb4 0x2120bb79c 0x23c197c38 0x100c4f464 0x20f97d8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException
The error seems linked to a memory issue (Unsupported value: Error Domain=com.google.mlkit Code=13 "Unable to initialize recognizer: generic::internal: Unable to mmap file descriptor (Cannot allocate memory), but I don't find the reason.
Do I have to release something after the digitalInkRecognizer.recognize() method is called? I can't find anything related to this in the documentation.
Thanks in advance for any idea.
I found that the issue was linked to the lifecycle management of the ModelManager and recognizer which I was recreating each time I was performing the digital ink recognition.
After changing this behaviour and keeping a reference to them once created, the issue was solved.
This example was helpful to understand how to work with the ModelManager (see implementation of the StrokeManager).
I am using a singleton class to select data from CoreData, and send it back to the calling ViewController. My issue is that when getting one of the ManagedObject's properties, the app crashes with an EXC_BAD_ACCESS exception.
This only seems to happen on iOS 9.x or on the simulator, but is pretty consistent on those. It hasn't happened on a device running 10.x. I set the scheme diagnostics to show zombie objects, and am now presented with the following error:
-[CFString copy]: message sent to deallocated instance 0x15b92990
The issue is that the string being referenced is on an object retrieved directly before I get this error, and I am using Swift (So not manually deallocating anything), so I don't understand why it is deallocated.
The code that selects the object looks like this:
func getModelTypePrice(mmCode: String, year: Int) -> ModelTypePrice? {
let request = NSFetchRequest<ModelTypePrice>(entityName: "ModelTypePrice")
request.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [NSPredicate(format: "mmcode = %#", mmCode),
NSPredicate(format: "reg_year = %d", year)])
do {
let prices = try managedContext.fetch(request)
if prices.count == 1 {
return prices[0]
}
} catch {
print("Error selecting object: \(error)")
}
return nil
}
That is called from the ViewController, and used as follows:
if let price = LibraryAPI.sharedInstance.getModelTypePrice(mmCode: "123", year: 2017) {
self.newPrice = price.new_price // Error happens here.
}
The ViewController does have an optional String property called newPrice. The new_price property on a ModelTypePrice is also an optional String.
I am at a bit of a loss here, so any advice or suggestions would be appreciated.
This fixed it: [CFNumber release]: message sent to deallocated instance
The problem was the name of the property of the managed object starting with new(it was new_price). Changing it to price_new fixed it. Apparently they changed how this is handled in iOS 10.x, as it was never a problem there.
Maybe this saves someone else some frustration.
I am using Google PlaceAutoComplete method to get suggestions of the Addess that is entered in textField.
func placeAutocomplete(text:String) {
let placesClient = GMSPlacesClient()
let filter = GMSAutocompleteFilter()
filter.type = .Address
placesClient.autocompleteQuery("New Delhi", bounds: nil, filter: nil) { (results, error) in
guard error == nil else {
print("Autocomplete error \(error)")
return
}
self.addressArray.removeAll()
for result in results! {
self.addressArray.append(result.attributedFullText.string)
print("Result \(result.attributedFullText.string) with placeID \(result.placeID)")
}
}
}
When i call this method. It crashes, say the Following error.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary boolValue]: unrecognized selector sent to instance 0x7fe338f01e40'
I have tried to found using exception breakpoint but doesn't work.
Can any have idea, where i am wrong?
I have resolved the issue by correcting in the plist for "allow arbitrary loads" in App Transport security Settings. I was typed it true but its type was set string instead for Boolean
Somewhere a NSDictionary is being passed to the code where it is expecting a something that can be interpreted as a boolean such as an NSString or NSNumber. I don't see anything like that in the code you provided. If exception breakpoints aren't working I would try adding normal breakpoints somewhere and stepping over code until it crashes. You could also try removing certain sections and code and seeing if the crash is still happening, this will let you narrow down what portion of your code is to blame.