Closed the-civilian closed 8 years ago
You're going to need to give us more information, what is the stack trace? What are you even trying to do? Which instructions?
You're a programmer, give us a bug report you'd like to see.
This is probably a noob mistake.
I gave this setup method (being called on - (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions):
[ARAnalytics setupWithAnalytics:@{
ARFlurryAPIKey : @"KEY HERE",
} configuration:@{
ARAnalyticsTrackedScreens : @[
@{
ARAnalyticsClass : ViewController.class,
ARAnalyticsDetails : @[
@{
ARAnalyticsPageNameKeyPath : @"title",
},
@{
ARAnalyticsEventName : @"button pressed",
ARAnalyticsSelectorName : ARAnalyticsSelector(buttonPressed:),
},
]
}
]
}];
[ARAnalytics incrementUserProperty:@"app launched count" byInt:1];
for this message:
- (IBAction)buttonPressed:(id)sender {
NSLog(@"button pressed");
}
This looks fine, you've set the right class?
I pushed a sample project where I could reproduce the error: https://github.com/the-civilian/just-a-button.git
Crashes with the following stack:
* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7fd0c3d272f0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key (null).' * First throw call stack: ( 0 CoreFoundation 0x000000010694af65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001063c4deb objc_exception_throw + 48 2 CoreFoundation 0x000000010694aba9 -[NSException raise] + 9 3 Foundation 0x0000000104a53e8c -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226 4 Foundation 0x00000001049a9f37 -[NSObject(NSKeyValueCoding) valueForKey:] + 280 5 JustAButton 0x000000010471c259 53+[ARAnalytics(DSL) addScreenMonitoringAnalyticsHook:]_block_invoke_4 + 201 6 JustAButton 0x00000001047eb35f -[RACSubscriber sendNext:] + 239 7 JustAButton 0x00000001047a802c -[RACPassthroughSubscriber sendNext:] + 444 8 JustAButton 0x00000001047ea5b4 23-[RACSubject sendNext:]_block_invoke + 68 9 JustAButton 0x00000001047ea3b3 -[RACSubject enumerateSubscribersUsingBlock:] + 595 10 JustAButton 0x00000001047ea547 -[RACSubject sendNext:] + 151 11 JustAButton 0x000000010478e8fb RACForwardInvocation + 347 12 JustAButton 0x000000010478e6fc RACSwizzleForwardInvocation_blockinvoke + 92 13 CoreFoundation 0x00000001068a0d97 forwarding_ + 487 14 CoreFoundation 0x00000001068a0b28 _CF_forwarding_prep_0 + 120 15 UIKit 0x0000000104f4f1fa -[UIApplication sendAction:to:from:forEvent:] + 92 16 UIKit 0x00000001050b3504 -[UIControl sendAction:to:forEvent:] + 67 17 UIKit 0x00000001050b37d0 -[UIControl _sendActionsForEvents:withEvent:] + 311 18 UIKit 0x00000001050b2906 -[UIControl touchesEnded:withEvent:] + 601 19 UIKit 0x0000000104fb9aa3 -[UIWindow _sendTouchesForEvent:] + 835 20 UIKit 0x0000000104fba691 -[UIWindow sendEvent:] + 865 21 UIKit 0x0000000104f6c752 -[UIApplication sendEvent:] + 263 22 UIKit 0x0000000104f47fcc _UIApplicationHandleEventQueue + 6693 23 CoreFoundation 0x00000001068770a1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 24 CoreFoundation 0x000000010686cfcc CFRunLoopDoSources0 + 556 25 CoreFoundation 0x000000010686c483 CFRunLoopRun + 867 26 CoreFoundation 0x000000010686be98 CFRunLoopRunSpecific + 488 27 GraphicsServices 0x0000000108f4ead2 GSEventRunModal + 161 28 UIKit 0x0000000104f4d676 UIApplicationMain + 171 29 JustAButton 0x0000000104712e8f main + 111 30 libdyld.dylib 0x0000000107edd92d start + 1 31 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
You're using the wrong keys for different sections, this is our example code:
[ARAnalytics setupWithAnalytics: @{ /* keys */ } configuration: @{
ARAnalyticsTrackedScreens: @[ @{
ARAnalyticsClass: UIViewController.class,
ARAnalyticsDetails: @[ @{
ARAnalyticsPageNameKeyPath: @"title",
}]
}],
ARAnalyticsTrackedEvents: @[@{
ARAnalyticsClass: MyViewController.class,
ARAnalyticsDetails: @[ @{
ARAnalyticsEventName: @"button pressed",
ARAnalyticsSelectorName: NSStringFromSelector(@selector(buttonPressed:)),
},
@{
ARAnalyticsEventName: @"switch switched",
ARAnalyticsSelectorName: NSStringFromSelector(@selector(switchSwitched:)),
}]
},
...
You need to use ARAnalyticsTrackedEvents
for tracked events, switching that in your example to this:
[ARAnalytics setupWithAnalytics:@{
ARFlurryAPIKey : @"KEY HERE",
} configuration:@{
ARAnalyticsTrackedScreens: @[ @{
ARAnalyticsClass: ViewController.class,
ARAnalyticsDetails: @[ @{
ARAnalyticsPageNameKeyPath: @"title",
}]
}],
ARAnalyticsTrackedEvents: @[@{
ARAnalyticsClass: ViewController.class,
ARAnalyticsDetails: @[ @{
ARAnalyticsEventName: @"button pressed",
ARAnalyticsSelectorName: NSStringFromSelector(@selector(buttonPressed:)),
}]
}]
}];
works :+1:
Noob mistake, worked! Thanks a lot!
I followed the documentation but I'm getting this error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7fe2b35299c0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key (null).'
Don't know if this is the correct place, didn't now where to get help.
Kind regards