I have a datePicker and I trying send the value but don't working it.
The Error:
-[__NSDate length]: unrecognized selector sent to instance 0x8ee2330
2014-06-30 13:49:42.602 Golf Tipp[2374:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate length]: unrecognized selector sent to instance 0x8ee2330'
**My Code:**
Confirmacion *cuartoView = (Confirmacion *)[segue destinationViewController];
NSDate *date = [self.fecha_hora date];
cuartoView.fecha = date;
You have an object of type NSDate. And somewhere you have code that believes the object is an NSString or maybe NSData (not NSDate), and sends a length message to it.
The usual way to find the problem is either: Stare at your code long and hard. Or: Set an exception breakpoint in Xcode and find where the problem happens, and deduce from that what you did wrong. If you don't know how to set an exception breakpoint in Xcode, feel free to use Google.
Related
Error: Unable to capture view hierarchy. Details: Log Title: Data
source expression execution failure. Log Details: error evaluating
expression “(id)[[(Class)objc_getClass("DBGTargetHub") sharedHub]
performRequestWithRequestInBase64:#"YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QFwcIGxwdHh8gISIuLzAxMjM0Nz1BQkNEVSRudWxs0wkKCwwTGldOUy5rZXlzWk5TLm9iamVjdHNWJGNsYXNzpg0ODxAREoACgAOABIAFgAaAB6YUFRYXGBmACIAJgBOAD4AUgBWAFl8QG0RCR0hpZXJhcmNoeVJlcXVlc3RQcmlvcml0eV8QHERCR0hpZXJhcmNoeVJlcXVlc3RQcmVkaWNhdGVfEBdEQkdIaWVyYXJjaHlSZXF1ZXN0TmFtZV8QHkRCR0hpZXJhcmNoeVJlcXVlc3RTcGluUnVubG9vcF8QHURCR0hpZXJhcmNoeVJlcXVlc3RJZGVudGlmaWVyXxAXREJHSGllcmFyY2h5UmVxdWVzdFR5cGUQANMJCgsjKC2kJCUmJ4AKgAuADIANpCkXKyuADoAPgBCAEIASXxATc3RyaWN0ZXN0VmlzaWJpbGl0eV8QEWluY2x1ZGVMYXp5VmFsdWVzXxATZW51bVByb3ZpZGVyQ2xhc3Nlc18QFm9wdGlvbnNQcm92aWRlckNsYXNzZXMQAwjSCgs1NqCAEdI4OTo7WiRjbGFzc25hbWVYJGNsYXNzZXNXTlNBcnJheaI6PFhOU09iamVjdNI4OT4/XxATTlNNdXRhYmxlRGljdGlvbmFyeaM+QDxcTlNEaWN0aW9uYXJ5XxAPSW5pdGlhbCByZXF1ZXN0XxAkQ0U4OUY0RkItRkRGRS00RUNGLUIwNzctMUQyNDk1REMzMjRCEAHSODlARaJAPF8QD05TS2V5ZWRBcmNoaXZlctFISVRyb290gAEACAARABoAIwAtADIANwBRAFcAXgBmAHEAeAB/AIEAgwCFAIcAiQCLAJIAlACWAJgAmgCcAJ4AoAC+AN0A9wEYATgBUgFUAVsBYAFiAWQBZgFoAW0BbwFxAXMBdQF3AY0BoQG3AdAB0gHTAdgB2QHbAeAB6wH0AfwB/wIIAg0CIwInAjQCRgJtAm8CdAJ3AokCjAKRAAAAAAAAAgEAAAAAAAAASgAAAAAAAAAAAAAAAAAAApM="]”:
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1,
address=0x0).
The process has been returned to the state before expression evaluation.
You likely have a bug somewhere in the implementation of a framework override. At least it was the case for me: a forced unwrapping of an optional nil value. Since the debugger executes the above statement, I could not get a stack trace of where the problem had happened.
My idea was to emulate the debugger's statement in my code directly. Since you won't have access to DBGTargetHub's interface, I went with using the Objective-C runtime functions.
NSString *data = #"YnBsaXN0MDDUAQIDBA[...]";
Class DbgTargetHub = objc_getClass("DBGTargetHub");
SEL sel = sel_getUid("sharedHub");
id sharedHub = ((id(*)(id, SEL))objc_msgSend)(DbgTargetHub, sel);
sel = sel_getUid("performRequestWithRequestInBase64:");
id result = ((id(*)(id, SEL, NSString*))objc_msgSend)(sharedHub, sel, data);
I was able to generate a stack trace from this which I could use to locate my problem.
Would be interested to know if this helped anybody.
For me this was a really weird SwiftUI bug caused by having a Section(header: that was a Divider view. Changed it to a Rectangle view and it all started working again...
I was only able to track this down by commenting out views until things worked again. Hope this helps some poor soul
I get this warning only on my first item on a table view once i go into the "drill down" view on a core data app.
anyone else got this warning?
-[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?
thanks
Xcode 7.2.1, iOS 9.2.1, ARC enabled
Check to see that the NSData object you are using to store data does not get released before it is accessed. You must check this at the place where the data is accessed, not in your view controller or else where.
-[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?
This warning is raised when the NSData object is empty. The sure way to check if it is or not, is to use [yourDataObject length] and make sure it is not zero.
Hope this helps! Cheers.
once I had met this problem, It's cause by...
NSString *str = #"ss";
NSString *temp = [str substringToIndex:4];
In iOS8.
now xCode8.1 will tell you
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSCFConstantString substringToIndex:]: Index 4 out of bounds; string length 2'
It seems that you are trying to read from an empty data object.
Maybe you initialize your data as [NSData data] before or your saved data is empty.
I am making an iphone app in xcode and I changed a few things and i got this error:
2012-01-01 10:55:40.295 Dodge Cars free[549:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x68912d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key RoadImage.'
*** First throw call stack:
(0x13cd052 0x155ed0a 0x13ccf11 0x9c4032 0x935f7b 0x935eeb 0x950d60 0x24391a 0x13cee1a 0x1338821 0x24246e 0x244010 0x2414a 0x24461 0x237c0 0x32743 0x331f8 0x26aa9 0x12b7fa9 0x13a11c5 0x1306022 0x130490a 0x1303db4 0x1303ccb 0x232a7 0x24a9b 0x1fc8 0x1f25 0x1)
terminate called throwing an exception
I don't know exactly what it means but the RoadImage it is referring to is a UIImageView in my .xib file. I have tried to clean the application but that doesn't seem to help. Any ideas?
maybe in your .h file you changed:
IBOutlet UIImage * RoadImage;
to something that fits with the naming convention:
IBOutlet UIImage * roadImage;
but in your xib you are still trying to connect to RoadImage, go look at your connection, I would guess that you have something connected that isn't valid anymore.
I figured out my problem in the xcode project information I didn't realize but I changed my main interface to my .xib file and for whatever reason that caused the problem.
I have some code that gets the URL from an array and stores it as a string then uses that string to load up the URL.
NSString *first = [urls objectAtIndex:[sender clickedRow]];
NSLog(#"%#", first);
[[webview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:first]]];
However, when I run this I get this error:
-[NSURL length]: unrecognized selector sent to instance 0x164dc0
The link in this case is http://www.digg.com
I know that the bug is in the line
NSString *first = [urls objectAtIndex:[sender clickedRow]];
because I tried setting the string's value directly to the URL instead of the array and it worked.
However, when I run this I get this error:
-[NSURL length]: unrecognized selector sent to instance 0x164dc0
First off, that's an exception, not an error.
When you get a message like this, read what it says:
-[NSURL
The object you sent this message to was an NSURL object.
length]:
The selector of the message was length.
Now, why would you send a length message to an NSURL object? You wouldn't, and you didn't do so yourself. Something else did.
But you would send a length message to a string object. So, you have an NSURL object, and you passed it somewhere that expected a string.
There's only one passage in the code you showed:
[NSURL URLWithString:first]
The exception tells you that first is already an NSURL; it is not a string. You do not need to create an NSURL from it, since it already is one, and trying to treat it as a string in any way will cause an exception.
You may be about to object to my claim on the grounds of this previous line:
NSString *first = [urls objectAtIndex:[sender clickedRow]];
Your objection would be that the declaration clearly says that first is a pointer to an NSString, so I must be wrong.
But that is not so. You declared first as a pointer to an NSString. That is to say, you told the compiler that the variable first would hold a pointer to an NSString.
But then you put a pointer to an NSURL into the variable.
In many cases, the compiler would warn you that you have lied to it, but it didn't in this case because the object came through objectAtIndex:, which returns id; thus, the compiler doesn't know what type of object you're putting into the variable. The compiler, assuming that you told the truth and really are putting an NSString here, does not warn for this initialization.
But you're not. The object is an NSURL, as you found out at run time.
The fix is two-fold:
Restore truth to the declaration, by declaring the variable as NSURL *, not NSString *.
Don't attempt to create an NSURL here, because you already have one.
If I get an error code result from a Cocoa function, is there any easy way to figure out what it means (other than by grepping through all the .h files in the framework bundles)?
You should look at the <Framework/FrameworkErrors.h> header for whatever framework the method you're using that's returning an error comes from.
For example, an NSError in the Cocoa domain that you get from a method in the Foundation framework will have its code property described in the <Foundation/FoundationErrors.h> header. Similarly with AppKit and <AppKit/AppKitErrors.h> and Core Data and <CoreData/CoreDataErrors.h>.
Also, if you print the description of the NSError in the debugger, it should include not only the error domain and code, but also the name of the actual error code constant so you can look it up in the API reference.
The sections on 'Error Domains' and 'Error Codes' in Apple's Error Handling Programming Guide address this reasonably well. You need to do the following:
Log the error, taking note of both the error domain (a human-readable / Googleable string that tells you where to look for the error code definitions) and the error code itself (an integer)
Sniff around on Google (or read from the list below) and figure out the name of the header file(s) where the error codes for that error domain are defined
Search those header file(s) for the error code you got. You should find both a constant name for the error code (like ENOMEM), and hopefully also an explanatory comment (like /* Cannot allocate memory */) explaining what the error means. If there's no comment, and the constant name isn't self-explanatory, just Google the constant name and you'll probably find a proper description.
Some header files of major error domains:
NSCocoaErrorDomain
Error code declarations are spread across three header files:
<Foundation/FoundationErrors.h> (Generic Foundation error codes)
<AppKit/AppKitErrors.h> (Generic AppKit error codes)
<CoreData/CoreDataErrors.h> (Core Data error codes)
NSURLErrorDomain
Check NSURLError.h
NSXMLParserErrorDomain
CheckNSXMLParser.h
NSMachErrorDomain
Check /usr/include/mach/kern_return.h
NSPOSIXErrorDomain
Check /usr/include/sys/errno.h
NSOSStatusErrorDomain
Check
/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MacErrors.h
Also, Cocoa's NSError is meant to be displayable to the end user. If you just log it, it should be readable.
If you're talking about Carbon's OSStatus and such, MacErrors.h.
For NSError errors add a line of code:
NSError *error;
// ... Some code that returns an error
// Get the error as a string
NSString *s = [error localizedDescription];
// Observe the code for yourself or display to the user.