App is crashing when I call defaultRealm - ios

I am trying to remove every instance of an RLMObject subclass and whenever I call [Realm defaultRealm] my app crashes. Here is what I keep getting in the console. I am using cocoapods, version 0.93.2
*** Terminating app due to uncaught exception 'RLMException', reason: 'Can't persist property 'Id' with incompatible type. Add to ignoredPropertyNames: method to ignore.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106b15c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001067aebb7 objc_exception_throw + 45
2 business_sect 0x000000010206251b -[RLMProperty initWithName:indexed:property:] + 571
3 business_sect 0x00000001020511c1 +[RLMObjectSchema propertiesForClass:isSwift:] + 1457
4 business_sect 0x000000010204fa5c +[RLMObjectSchema schemaForObjectClass:] + 812
5 business_sect 0x00000001020c4d06 +[RLMSchema initialize] + 1862
6 libobjc.A.dylib 0x00000001067af4d6 _class_initialize + 648
7 libobjc.A.dylib 0x00000001067b86e1 lookUpImpOrForward + 351
8 libobjc.A.dylib 0x00000001067c50d3 objc_msgSend + 211
9 business_sect 0x00000001020aa34d +[RLMRealm realmWithPath:key:readOnly:inMemory:dynamic:schema:error:] + 4765
10 business_sect 0x00000001020a8d78 +[RLMRealm realmWithPath:readOnly:error:] + 152
11 business_sect 0x00000001020a8bdf +[RLMRealm defaultRealm] + 111
12 business_sect 0x0000000101f386ff __40-[CGCUserManager signInUser:completion:]_block_invoke + 879
13 business_sect 0x0000000101fd39d8 __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke46 + 40
14 libdispatch.dylib 0x0000000107095186 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x00000001070b4614 _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010709ca1c _dispatch_main_queue_callback_4CF + 1664
17 CoreFoundation 0x0000000106a7d1f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
18 CoreFoundation 0x0000000106a3edcb __CFRunLoopRun + 2043
19 CoreFoundation 0x0000000106a3e366 CFRunLoopRunSpecific + 470
20 GraphicsServices 0x0000000107d63a3e GSEventRunModal + 161
21 UIKit 0x0000000104e6d8c0 UIApplicationMain + 1282
22 business_sect 0x0000000101f6927f main + 111
23 libdyld.dylib 0x00000001070e8145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
EDIT: I am also testing on the iphone6 simulator
Here is the RLMObject subclass:
#import "RLMObject.h"
#interface CGCUser : RLMObject
#property NSString *EmailAddress;
#property BOOL IsActive;
#end
And a second object
#interface CGCCardInfo : RLMObject
#property NSInteger *Id;
#property NSString *nickName;
#property NSString *token;
#property NSString *displayNumber;
#property BOOL *isDefault;
#property NSString *cardType;
#end
RLM_ARRAY_TYPE(CGCCardInfo)

The issue there is the line #property BOOL *isDefault;
If you change that to #property BOOL isDefault; it should do exactly what you want!

The same happened to me.
#property NSInteger *Id is the problematic field over here. You use a pointer to NSInteger instead of NSInteger itself.
The solution is to replace it with a direct reference: #property NSInteger Id

Related

After I conneted the UIVIew to my code,it crashed,why?

I press on CONTROL and drag the UIImageVIew and UILabel which is in AppView.xib to my code file named "AppVIew.h". Before I connect the two UI widgets it ran ok ,I want to know the reasons leading to the crash.Very thanks for your answers.
#property
The code as following:
#import <UIKit/UIKit.h>
#interface AppView : UIView
#property (weak, nonatomic) IBOutlet UIImageView *icon;
#property (weak, nonatomic) IBOutlet UILabel *name;
+ (id)AppViewWithIcon:(NSString *)icon Name:(NSString *)name;
#end
#import "AppView.h"
#implementation AppView
+ (id)AppViewWithIcon:(NSString *)icon Name:(NSString *)name{
AppView *view = [[NSBundle mainBundle] loadNibNamed:#"AppView" owner:nil options:nil][0];
NSLog(#"%#",view);
return view;
}
the errors as following:
1.Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode=0X0)
2.2016-03-27 18:53:36.804 05-九宫格[4302:283744] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x7fca52c1a1c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key icon.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101630d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001010a4deb objc_exception_throw + 48
2 CoreFoundation 0x00000001016309c9 -[NSException raise] + 9
3 Foundation 0x0000000100c6f19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000101db07fb -[UIRuntimeOutletConnection connect] + 109
5 CoreFoundation 0x000000010156a890 -[NSArray makeObjectsPerformSelector:] + 224
6 UIKit 0x0000000101daf1de -[UINib instantiateWithOwner:options:] + 1864
7 UIKit 0x0000000101db1415 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 223
8 05-九宫格 0x0000000100ba1490 +[AppView AppViewWithIcon:Name:] + 160
9 05-九宫格 0x0000000100ba0cae -[ViewController viewDidLoad] + 206
10 UIKit 0x0000000101b81984 -[UIViewController loadViewIfRequired] + 1198
11 UIKit 0x0000000101b81cd3 -[UIViewController view] + 27
12 UIKit 0x0000000101a57fb4 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000101a5869d -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000101a6a180 -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x00000001019deed9 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x00000001019e5568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
17 UIKit 0x00000001019e2714 -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x000000010444f8c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19 FrontBoardServices 0x000000010444f741 -[FBSSerialQueue _performNext] + 178
20 FrontBoardServices 0x000000010444faca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x0000000101556301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x000000010154c22c __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x000000010154b6e3 __CFRunLoopRun + 867
24 CoreFoundation 0x000000010154b0f8 CFRunLoopRunSpecific + 488
25 UIKit 0x00000001019e1f21 -[UIApplication _run] + 402
26 UIKit 0x00000001019e6f09 UIApplicationMain + 171
27 05-九宫格 0x0000000100ba195f main + 111
28 libdyld.dylib 0x0000000103e0a92d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Check if their are any previous outlets that have been deleted from within the storyboard, by either checking the view controller inspector and referencing outlets for any outlets that may contradict the ones you have made as well as the UIView/UILabel.

How to map local NSDictionary into a custom Object using RKMappingOperation?

RJobObject * jobObj = [RJobObject new];
RKMappingOperation *mappingOperation = [[RKMappingOperation alloc] initWithSourceObject:jobDictionary destinationObject:jobObj mapping:[RJobObject mapping]];
mappingOperation.dataSource = (id)jobObj;
[mappingOperation start];
jobDictionary structure:
NSDictionary *msg1 = #{
#"id" : #"dfcd",
#"message" : #"ndjfcdfcd"
};
NSDictionary *msg2 = #{
#"id" : #"fjvdfv",
#"message" : #"kjndcdovc"
};
NSDictionary *msg3 = #{
#"id" : #"fce",
#"message" : #"dfcdf"
};
NSArray *msgsArray = [NSArray arrayWithObjects:msg1, msg2,msg3, nil];
NSMutableDictionary * jobDictionary = [NSMutableDictionary dictionaryWithDictionary:#{#"id" : #"Sourabh pant",
#"title": #"http://www.google.com"
}];
[jobDictionary setObject:msgsArray forKey:#"messages"];
/......................................................./
RJobObject is the custom object:
#property (nonatomic) NSString * id;
#property (nonatomic) long long duration;
#property (nonatomic) NSString * title;
#property (nonatomic) NSString * image;
#property (nonatomic) NSString * secret;
#property (nonatomic) NSInteger unreadCount;
#property (nonatomic) NSArray * messages;
This creates a crash inside RRestkit, if the jobDictionary contains messages.If the messages array inside jobDictionary is empty,then the code runs fine.
So to sum up the message array is not being mapped.
Stack trace
2015-11-28 15:59:22.808 Checking Rest Kit[35951:3402596] -
[RJobObject mappingOperation:targetObjectForRepresentation:withMapping:inRelationship:]: unrecognized selector sent to instance 0x79f96270
2015-11-28 16:00:48.987 Checking Rest Kit[35951:3402596] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RJobObject mappingOperation:targetObjectForRepresentation:withMapping:inRelationship:]: unrecognized selector sent to instance 0x79f96270'
*** First throw call stack:
(
0 CoreFoundation 0x018e3a14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x013a2e02 objc_exception_throw + 50
2 CoreFoundation 0x018ecd63 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0182a6bd ___forwarding___ + 1037
4 CoreFoundation 0x0182a28e _CF_forwarding_prep_0 + 14
5 Checking Rest Kit 0x00142f48 -[RKMappingOperation destinationObjectForMappingRepresentation:parentRepresentation:withMapping:inRelationship:] + 1704
6 Checking Rest Kit 0x00149885 __64-[RKMappingOperation mapOneToManyRelationshipWithValue:mapping:]_block_invoke + 149
7 CoreFoundation 0x018152e9 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 73
8 CoreFoundation 0x01815182 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 162
9 CoreFoundation 0x017ff835 -[NSArray enumerateObjectsUsingBlock:] + 53
10 Checking Rest Kit 0x0014920b -[RKMappingOperation mapOneToManyRelationshipWithValue:mapping:] + 2763
11 Checking Rest Kit 0x0014b4fb -[RKMappingOperation applyRelationshipMappings] + 6283
12 Checking Rest Kit 0x0014d7db -[RKMappingOperation main] + 4075
13 Checking Rest Kit 0x0014c7dd -[RKMappingOperation start] + 45
14 Checking Rest Kit 0x000ab866 -[ViewController jobObjectFromJobDictionary:] + 310
15 Checking Rest Kit 0x000ab6d5 -[ViewController fetchJobFromDbForId:] + 85
16 Checking Rest Kit 0x000ab566 -[ViewController viewDidLoad] + 918
17 UIKit 0x01e3b2ae -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 44
18 UIKit 0x01e3fdce -[UIViewController loadViewIfRequired] + 1384
19 UIKit 0x01e401ed -[UIViewController view] + 35
20 UIKit 0x01cedf94 -[UIWindow addRootViewControllerViewIfPossible] + 69
21 UIKit 0x01cee6b1 -[UIWindow _setHidden:forced:] + 304
22 UIKit 0x01ceea67 -[UIWindow _orderFrontWithoutMakingKey] + 49
23 UIKit 0x01d02118 -[UIWindow makeKeyAndVisible] + 80
24 UIKit 0x01c6a6e7 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4190
25 UIKit 0x01c71cd6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1989
26 UIKit 0x01c96ee5 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3218 + 68
27 UIKit 0x01c6e966 -[UIApplication workspaceDidEndTransaction:] + 163
28 FrontBoardServices 0x04c4dc76 __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
29 FrontBoardServices 0x04c4d74d __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
30 FrontBoardServices 0x04c6b173 -[FBSSerialQueue _performNext] + 184
31 FrontBoardServices 0x04c6b5aa -[FBSSerialQueue _performNextFromRunLoopSource] + 52
32 FrontBoardServices 0x04c6a8a6 FBSSerialQueueRunLoopSourceHandler + 33
33 CoreFoundation 0x017fd6ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
34 CoreFoundation 0x017f338b __CFRunLoopDoSources0 + 523
35 CoreFoundation 0x017f27a8 __CFRunLoopRun + 1032
36 CoreFoundation 0x017f20e6 CFRunLoopRunSpecific + 470
37 CoreFoundation 0x017f1efb CFRunLoopRunInMode + 123
38 UIKit 0x01c6e206 -[UIApplication _run] + 540
39 UIKit 0x01c73bfa UIApplicationMain + 160
40 Checking Rest Kit 0x000af02a main + 138
41 libdyld.dylib 0x03911a21 start + 1
42 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
In Rconnection.m
- (id)destinationObjectForMappingRepresentation:(id)representation parentRepresentation:(id)parentRepresentation withMapping:(RKMapping *)mapping inRelationship:(RKRelationshipMapping *)relationshipMapping {
/* Some Code */
............
if (destinationObject == nil)
{
NSDictionary *dictionaryRepresentation = [representation isKindOfClass:[NSDictionary class]] ? representation : #{ [NSNull null] : representation };
RKMappingMetadata *parentMetadata = [RKMappingMetadata new];
parentMetadata.parentObject = self.destinationObject ?: [NSNull null];
NSArray *metadata = RKInsertInMetadataList(self.metadataList, parentMetadata, nil);
RKMappingSourceObject *sourceObject = [[RKMappingSourceObject alloc] initWithObject:dictionaryRepresentation parentObject:parentRepresentation rootObject:self.rootSourceObject metadata:metadata];
// Crashing Breakpoint below:
destinationObject = [dataSource mappingOperation:self targetObjectForRepresentation:(NSDictionary *)sourceObject withMapping:concreteMapping inRelationship:relationshipMapping];
}
.......
/* Some code */
}
#import <Foundation/Foundation.h>
#import <RestKit/RestKit.h>
#interface RJobObject : NSObject
#property (nonatomic) NSString * id;
#property (nonatomic) long long duration;
#property (nonatomic) NSString * title;
#property (nonatomic) NSString * image;
#property (nonatomic) NSString * secret;
#property (nonatomic) NSInteger unreadCount;
#property (nonatomic) NSArray * messages;
+(RKObjectMapping *)mapping;
#end
This line is incorrect:
mappingOperation.dataSource = (id)jobObj;
because you are giving the operation a plain data model object as a data source (and telling the compiler to like it by casting to id).
When the operation runs it needs some new instances to be created so it can map the content from the JSON dict into them, this is a job the data source is supposed to do. When the operation asks the data source you get a crash because the object you provided as the data source, jobObj, doesn't understand the request.
You need to create and set an appropriate data source that can handle this requirement.

Facebook IOS SDK navigate to another controller after login not working

I have followed all the steps mentioned in Facebook IOS SDK Docs.
My ViewController.h file is as below
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
#interface ViewController : UIViewController <FBLoginViewDelegate>
#end
My ViewController.m file is as below
#import "AppDelegate.h"
#import "ViewController.h"
#import "pageLike.h"
#interface ViewController ()
#property (weak, nonatomic) IBOutlet FBLoginView *fbloginbtn;
#property (weak, nonatomic) IBOutlet UILabel *name;
#property (weak, nonatomic) IBOutlet FBProfilePictureView *fbimage;
#property (weak, nonatomic) IBOutlet UILabel *status;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.fbloginbtn.readPermissions = #[#"public_profile",#"email",#"user_friends"];
self.fbloginbtn.publishPermissions = #[#"publish_actions"];
self.fbloginbtn.delegate =self;
// Do any additional setup after loading the view, typically from a nib.
if(FBSessionStateOpen){
pageLike *pg=[self.storyboard instantiateViewControllerWithIdentifier:#"pageLike"];
[self.navigationController pushViewController:pg animated:YES];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
self.fbimage.profileID=user.id;
self.name.text = user.name;
}
#end
And Error trace is as under
2014-12-31 17:59:09.830 fbconnect[2274:96019] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: __view_impression_identifier__)'
*** First throw call stack:
(
0 CoreFoundation 0x0110a946 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x009f2a97 objc_exception_throw + 44
2 CoreFoundation 0x00ffdbbc -[__NSDictionaryM setObject:forKey:] + 940
3 CoreFoundation 0x0107a210 -[NSMutableDictionary setObject:forKeyedSubscript:] + 48
4 fbconnect 0x0007c1b8 -[FBViewImpressionTracker logImpressionWithView:identifier:parameters:] + 76
5 fbconnect 0x000a8428 -[FBLikeControl drawRect:] + 183
6 UIKit 0x0175c95c -[UIView(CALayerDelegate) drawLayer:inContext:] + 519
7 QuartzCore 0x04ef9d61 -[CALayer drawInContext:] + 118
8 QuartzCore 0x04ef9c97 _ZL16backing_callbackP9CGContextPv + 96
9 QuartzCore 0x04dde4fe CABackingStoreUpdate_ + 2788
10 QuartzCore 0x04ef9c2f ___ZN2CA5Layer8display_Ev_block_invoke + 93
11 QuartzCore 0x04f2f416 x_blame_allocations + 15
12 QuartzCore 0x04ef9a95 _ZN2CA5Layer8display_Ev + 1591
13 QuartzCore 0x04ef9ce6 -[CALayer _display] + 33
14 QuartzCore 0x04ef9456 _ZN2CA5Layer7displayEv + 142
15 QuartzCore 0x04ef9cc0 -[CALayer display] + 33
16 QuartzCore 0x04eedef6 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 322
17 QuartzCore 0x04eedf7c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 38
18 QuartzCore 0x04e4c3c6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
19 QuartzCore 0x04e4d78c _ZN2CA11Transaction6commitEv + 392
20 QuartzCore 0x04e4de58 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
21 CoreFoundation 0x0102d9de __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
22 CoreFoundation 0x0102d920 __CFRunLoopDoObservers + 400
23 CoreFoundation 0x0102335a __CFRunLoopRun + 1226
24 CoreFoundation 0x01022bcb CFRunLoopRunSpecific + 443
25 CoreFoundation 0x010229fb CFRunLoopRunInMode + 123
26 GraphicsServices 0x028da24f GSEventRunModal + 192
27 GraphicsServices 0x028da08c GSEventRun + 104
28 UIKit 0x016d18b6 UIApplicationMain + 1526
29 fbconnect 0x00079a0d main + 141
30 libdyld.dylib 0x060dcac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I have created another view controller named pageLike where i need to actually navigate once user is logged in
Check the pageLike controller and remove all the fb login view controller as they might be creating issues .

xcode - unrecognized selector sent to instance

I called method in another class (they are both singletons).
WebserviceHelper.h
#interface WebserviceHelper : NSObject {
int currentType;
NSString *SERVER_URL;
WebserviceManager *webService;
}
#property (nonatomic, assign) id delegate;
- (void)retrieveStudentwithCode:(NSString *)code {
currentType = STUDENT_TYPE;
NSString *param = [NSString stringWithFormat:#"token=uencom&cid=%#", code];
NSString *link = [NSString stringWithFormat:#"%#getStudentInfo", SERVER_URL];
[webService retrieveData:link withParameters:param];
}
After call webservice and get data it cached here in received data. I check and it works fine
but when it deliver to didFinishLoading error happen here
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)receivedData {
data = [NSMutableData new];
[data appendData:receivedData];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self stopPostingToWebservice];
//it carsh here
[delegate: data];
}
Call stack:
2014-08-20 10:39:05.187 School-Link[1030:60b] -[WebserviceHelper :]: unrecognized selector sent to instance 0xa88a420
2014-08-20 10:39:05.188 School-Link[1030:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WebserviceHelper :]: unrecognized selector sent to instance 0xa88a420'
*** First throw call stack:
(
0 CoreFoundation 0x01bf31e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018f08e5 objc_exception_throw + 44
2 CoreFoundation 0x01c90243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01be350b ___forwarding___ + 1019
4 CoreFoundation 0x01be30ee _CF_forwarding_prep_0 + 14
5 School-Link 0x00030c82 -[WebserviceManager connectionDidFinishLoading:] + 242
6 Foundation 0x016b9e49 ___NSURLConnectionDidFinishLoading_block_invoke + 40
7 Foundation 0x016507e1 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 62
8 Foundation 0x014d8f5e -[NSURLConnectionInternalConnection invokeForDelegate:] + 119
9 Foundation 0x014d8ec6 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 208
10 Foundation 0x014d8dd8 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76
11 Foundation 0x014d9188 _NSURLConnectionDidFinishLoading + 43
12 CFNetwork 0x02a3169f ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 111
13 CFNetwork 0x02a2f3de ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 104
14 CoreFoundation 0x01b94c69 CFArrayApplyFunction + 57
15 CFNetwork 0x02998441 _ZN19RunloopBlockContext7performEv + 155
16 CFNetwork 0x02a7a3f4 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20
17 CFNetwork 0x02998257 _ZN17MultiplexerSource7performEv + 299
18 CFNetwork 0x0299806c _ZN17MultiplexerSource8_performEPv + 76
19 CoreFoundation 0x01b7c77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x01b7c1d5 __CFRunLoopDoSources0 + 437
21 CoreFoundation 0x01b991ae __CFRunLoopRun + 910
22 CoreFoundation 0x01b989d3 CFRunLoopRunSpecific + 467
23 CoreFoundation 0x01b987eb CFRunLoopRunInMode + 123
24 GraphicsServices 0x0338d5ee GSEventRunModal + 192
25 GraphicsServices 0x0338d42b GSEventRun + 104
26 UIKit 0x005b0f9b UIApplicationMain + 1225
27 School-Link 0x00018f6d main + 141
28 libdyld.dylib 0x03026701 start + 1
29 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Try this, have a protocol declaration in WebserviceHelper.h like
#protocol studentDataDelegate <NSObject>
-(void)WebserviceHelper:(WebserviceHelper *)webserviceHelper didStudentDataDownloadCompleteWithData:(NSMutableData *)data;
#end
WebserviceHelper.m
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self stopPostingToWebservice];
[self.delegate WebserviceHelper:self didStudentDataDownloadCompleteWithData:data];
}
so which ever class confirms to the above protocol should implement the delegate method like,
#interface RequestingDataClass : UIViewController <studentDataDelegate>
by doing this you will receive the warning that you have not implemented didStudentDataDownloadCompleteWithData:method so do it like
-(void)WebserviceHelper:(WebserviceHelper *)webserviceHelper didStudentDataDownloadCompleteWithData:(NSMutableData *)data;
{
webserviceHelper.delegate=self;
// Do something with the `data`
}
You do no show the declaration of the delegate, however this statement:
[delegate: data];
Should be:
[delegate haveSomeData:data];
(or something similar)
did you create protocol in your WebserviceHelper.h file like this?
#protocol WebserviceHelperDelegate <NSObject>
#required
-(void)reciveData:(NSData *)data;//or your method
#end
decleare a property
#property (nonatomic,strong) id <WebserviceHelperDelegate> delegate;
then call this method like
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self stopPostingToWebservice];
//it carsh here
[self.delegate reciveData: data];
}
And implement this method from where you call webservice class and assign delegate
-(void)reciveData:(NSData *)data{
}

NSManaged Object initWithCoder Error

I have a nasty bug and I would appreciate any guidance pointing me in the general direction of a solution. Occasionally, I get the following exception which pertains to calling initWithCoder on 3 different NSManagedObject subclasses in my core data model. If I delete the app from my device and reload it, or reset content on the simulator the exception goes away. No where in my code do I explicitly call initWithCoder on an NSManagedObject Subclass.
The bug seems to arise randomly after editing random parts of my source code. Any ideas on where to begin?
2014-01-11 15:59:22.078 Flip Evaluator and Manager[354:a0b] -[SellingCosts initWithCoder:]: unrecognized selector sent to instance 0xc2cec80
2014-01-11 15:59:22.079 Flip Evaluator and Manager[354:a0b] CoreData: error: exception during fetchRowForObjectID: -[SellingCosts initWithCoder:]: unrecognized selector sent to instance 0xc2cec80 with userInfo of (null)
2014-01-11 15:59:22.081 Flip Evaluator and Manager[354:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SellingCosts initWithCoder:]: unrecognized selector sent to instance 0xc2cec80'
*** First throw call stack:
(
0 CoreFoundation 0x01e9a5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01c1d8b6 objc_exception_throw + 44
2 CoreFoundation 0x01f37903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01e8a90b ___forwarding___ + 1019
4 CoreFoundation 0x01e8a4ee _CF_forwarding_prep_0 + 14
5 Foundation 0x01830b2a _decodeObjectBinary + 3498
6 Foundation 0x0182fc15 _decodeObject + 340
7 Foundation 0x0182fab9 -[NSKeyedUnarchiver decodeObjectForKey:] + 181
8 Foundation 0x018a168d +[NSKeyedUnarchiver unarchiveObjectWithData:] + 106
9 Foundation 0x018202e5 -[_NSKeyedUnarchiveFromDataTransformer transformedValue:] + 47
10 CoreData 0x0064bd09 _prepareResultsFromResultSet + 4105
11 CoreData 0x00649583 newFetchedRowsForFetchPlan_MT + 1795
12 CoreData 0x0063448e -[NSSQLCore newRowsForFetchPlan:] + 526
13 CoreData 0x0065302e -[NSSQLCore fetchRowForObjectID:] + 1198
14 CoreData 0x00650798 -[NSSQLCore newValuesForObjectWithID:withContext:error:] + 296
15 CoreData 0x00650667 -[NSPersistentStoreCoordinator(_NSInternalMethods) newValuesForObjectWithID:withContext:error:] + 71
16 CoreData 0x0064fa3b _PFFaultHandlerLookupRow + 411
17 CoreData 0x0064f897 -[NSFaultHandler fulfillFault:withContext:forIndex:] + 39
18 CoreData 0x0064f473 _PF_FulfillDeferredFault + 259
19 CoreData 0x0064f2c6 _sharedIMPL_pvfk_core + 70
20 CoreData 0x00653cd5 -[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) _genericValueForKey:withIndex:flags:] + 85
21 CoreData 0x0068d781 _PF_Handler_Public_GetProperty + 161
22 CoreData 0x0068d685 -[NSManagedObject valueForKey:] + 149
23 Flip Evaluator and Manager 0x00030c4c -[OzCalculator sumTheValuesInSet:withAttributeKeyForValue:] + 428
24 Flip Evaluator and Manager 0x0002f7d5 -[OzCalculator sumMoreCostsAndUpdateDataModelFor:] + 165
25 Flip Evaluator and Manager 0x0002edc1 -[OzCalculator performAllCalculationsOnProperty:] + 817
26 Flip Evaluator and Manager 0x00002d37 -[OzPropertyConverter createAManagedPropertyFromAnEvaluatedProperty:] + 1175
27 Flip Evaluator and Manager 0x00041233 -[OzHaveYouPurchasedThisProperty goForwardToNextView] + 307
28 libobjc.A.dylib 0x01c2f874 -[NSObject performSelector:withObject:withObject:] + 77
29 UIKit 0x0098d0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
30 UIKit 0x0098d04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
31 UIKit 0x00a850c1 -[UIControl sendAction:to:forEvent:] + 66
32 UIKit 0x00a85484 -[UIControl _sendActionsForEvents:withEvent:] + 577
33 UIKit 0x00a841fd -[UIControl touchesBegan:withEvent:] + 254
34 UIKit 0x009ca34b -[UIWindow _sendTouchesForEvent:] + 386
35 UIKit 0x009cb184 -[UIWindow sendEvent:] + 1232
36 UIKit 0x0099ee86 -[UIApplication sendEvent:] + 242
37 UIKit 0x0098918f _UIApplicationHandleEventQueue + 11421
38 CoreFoundation 0x01e2383f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
39 CoreFoundation 0x01e231cb __CFRunLoopDoSources0 + 235
40 CoreFoundation 0x01e4029e __CFRunLoopRun + 910
41 CoreFoundation 0x01e3fac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x01e3f8db CFRunLoopRunInMode + 123
43 GraphicsServices 0x02c2a9e2 GSEventRunModal + 192
44 GraphicsServices 0x02c2a809 GSEventRun + 104
45 UIKit 0x0098bd3b UIApplicationMain + 1225
46 Flip Evaluator and Manager 0x0002e5dd main + 141
47 libdyld.dylib 0x030c1725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Code:
//
// SellingCosts.h
// Flip Evaluator and Manager
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#class Cost, Property, TotalCosts;
#interface SellingCosts : NSManagedObject
#property (nonatomic, strong) NSNumber * deedPrep;
#property (nonatomic, strong) NSNumber * realtyCommisionAmount;
#property (nonatomic, strong) NSNumber * realtyCommisionPercent;
#property (nonatomic, strong) NSNumber * totalCost;
#property (nonatomic, strong) NSSet *moreCosts;
#property (nonatomic, strong) Property *property;
#property (nonatomic, strong) TotalCosts *totalCosts;
#property (nonatomic, strong) NSNumber * transferTaxAmount;
#property (nonatomic, strong) NSNumber * transferTaxPercent;
#property (nonatomic, strong) NSNumber *totalIncompleteCost;
#property (nonatomic, strong) NSNumber *totalCompleteCost;
#end
Here is the method that is called before things go wrong:
-(NSInteger)sumTheValuesInSet:(NSMutableSet *)set withAttributeKeyForValue:(NSString *)attributeKey
{
NSInteger sumToReturn = 0;
for (id obj in set) {
sumToReturn = sumToReturn +[[obj valueForKey:attributeKey] integerValue];
}
return sumToReturn;
}
The method enumerates through Cost objects in the NSSet [sellingCosts valueForKey:#"moreCosts"].
Here is the model for the Cost object//
// Cost.h
// Flip Evaluator and Manager
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#class BuyingCosts, HoldingCosts, SellingCosts, OtherCosts, TotalCosts;
#interface Cost : NSManagedObject
#property (nonatomic, strong) BuyingCosts *buyingCosts;
#property (nonatomic, strong) HoldingCosts *holdingCosts;
#property (nonatomic, strong) SellingCosts *sellingCosts;
#property (nonatomic, strong) OtherCosts *otherCosts;
#property (nonatomic, strong) NSString * name;
#property (nonatomic, strong) TotalCosts *incompleteCosts;
#property (nonatomic, strong) TotalCosts *completedCosts;
#property (nonatomic, strong) NSNumber *complete;
#property (nonatomic, strong) id costType;
#property (nonatomic, strong) NSNumber *amount;
#end
Share your model as well as this appears to be a transform problem at first glance.
You should also share the code in -sumTheValuesInSet:withAttributeKeyForValue: as that seems to be the last point in your code before things go wrong.

Resources