Backendless:删除第一个 table 中的行,当另一个 table 中的相关行被删除时
Backendless: delete row in 1st table when related row in another table is deleted
我有两个 table。用户收藏夹和操作。 UserFavourites 将 Action 作为其 属性(列)。当在 Action table 中删除相关 Action 时,我希望系统删除 UserFavourite 行。目前,当我在 Action table 中删除一行,即 UserFavourites 的 child 时,UserFavourites 的 Action 列为空列,但它并没有像我希望的那样被删除。
非常感谢!
编辑:
我想我应该加载相关的 UserFavourites object 并像这样删除它:
ActionCreation* uf = [self.myActions objectAtIndex:self.selectedIndex.row];
BackendlessDataQuery *query = [BackendlessDataQuery query];
Fault *fault=nil;
query.whereClause = [NSString stringWithFormat:@"favouriteAction.objectId =\'%@\'", [uf objectId]];
@try{
BackendlessCollection* relatedUserFavourites =[backendless.persistenceService load:uf relations:@[@"*"]error:&fault];
//code for delteing from backendless
}@catch (Fault *fault) {
NSLog(@"FAULT = %@ <%@>", fault.message, fault.detail);
}
但我得到异常:
-[ActionCreation allKeys]: unrecognized selector sent to instance 0x7fa8b0fc59c0
2015-03-11 19:57:03.157 ActionPlusChetech[1468:76482] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ActionCreation allKeys]: unrecognized selector sent to instance 0x7fa8b0fc59c0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c476a75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c10fbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010c47dd1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010c3d59dc ___forwarding___ + 988
4 CoreFoundation 0x000000010c3d5578 _CF_forwarding_prep_0 + 120
5 ActionPlusChetech 0x00000001098322a2 -[PersistenceService load:relations:] + 331
6 ActionPlusChetech 0x0000000109830ed7 -[PersistenceService load:relations:error:] + 30
7 ActionPlusChetech 0x00000001097f4bb7 -[MyActionsVC deleteButtonTapped] + 1767
8 ActionPlusChetech 0x00000001097f66be -[MyActionsVC pushMenuItem:] + 526
9 Foundation 0x000000010a611e3a -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 900
10 Foundation 0x000000010a611971 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 132
11 ActionPlusChetech 0x00000001097f750d -[KxMenuItem performAction] + 157
12 ActionPlusChetech 0x00000001097f9940 -[KxMenuView performAction:] + 208
13 UIKit 0x000000010abc9a22 -[UIApplication sendAction:to:from:forEvent:] + 75
14 UIKit 0x000000010acd0e50 -[UIControl _sendActionsForEvents:withEvent:] + 467
15 UIKit 0x000000010acd021f -[UIControl touchesEnded:withEvent:] + 522
16 UIKit 0x000000010af77e80 _UIGestureRecognizerUpdate + 9487
17 UIKit 0x000000010ac0f856 -[UIWindow _sendGesturesForEvent:] + 1041
18 UIKit 0x000000010ac10483 -[UIWindow sendEvent:] + 667
19 UIKit 0x000000010abdcfb1 -[UIApplication sendEvent:] + 246
20 UIKit 0x000000010abea227 _UIApplicationHandleEventFromQueueEvent + 17700
21 UIKit 0x000000010abc523c _UIApplicationHandleEventQueue + 2066
22 CoreFoundation 0x000000010c3abc91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x000000010c3a1b5d __CFRunLoopDoSources0 + 269
24 CoreFoundation 0x000000010c3a1194 __CFRunLoopRun + 868
25 CoreFoundation 0x000000010c3a0bc6 CFRunLoopRunSpecific + 470
26 GraphicsServices 0x000000010ef49a58 GSEventRunModal + 161
27 UIKit 0x000000010abc8580 UIApplicationMain + 1282
28 ActionPlusChetech 0x00000001097ea9e3 main + 115
29 libdyld.dylib 0x000000010d106145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我不太明白这个错误。 -[ActionCreation allKeys]:
和taht有什么关系?并且没有捕获到 Backendless 异常。
谢谢。
好吧,我找到了解决方法。不完全是我想要的,但它有效。因为 UserFavourites 在删除相关操作 object 后有空列,我的应用程序抛出异常,因为它获取的值为空。所以我决定,每次用户加载他的收藏夹时,检查 Action 列是否为空,如果是 - 他们发送请求删除 UserFavourites object。遗憾的是,我无法想出一种方法使这两列像 SQL 一样相互依赖,例如更新时、删除时等等。但是,嘿,它有效!)希望这对遇到此问题的人有所帮助。
我有两个 table。用户收藏夹和操作。 UserFavourites 将 Action 作为其 属性(列)。当在 Action table 中删除相关 Action 时,我希望系统删除 UserFavourite 行。目前,当我在 Action table 中删除一行,即 UserFavourites 的 child 时,UserFavourites 的 Action 列为空列,但它并没有像我希望的那样被删除。 非常感谢!
编辑: 我想我应该加载相关的 UserFavourites object 并像这样删除它:
ActionCreation* uf = [self.myActions objectAtIndex:self.selectedIndex.row];
BackendlessDataQuery *query = [BackendlessDataQuery query];
Fault *fault=nil;
query.whereClause = [NSString stringWithFormat:@"favouriteAction.objectId =\'%@\'", [uf objectId]];
@try{
BackendlessCollection* relatedUserFavourites =[backendless.persistenceService load:uf relations:@[@"*"]error:&fault];
//code for delteing from backendless
}@catch (Fault *fault) {
NSLog(@"FAULT = %@ <%@>", fault.message, fault.detail);
}
但我得到异常:
-[ActionCreation allKeys]: unrecognized selector sent to instance 0x7fa8b0fc59c0
2015-03-11 19:57:03.157 ActionPlusChetech[1468:76482] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ActionCreation allKeys]: unrecognized selector sent to instance 0x7fa8b0fc59c0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c476a75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c10fbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010c47dd1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010c3d59dc ___forwarding___ + 988
4 CoreFoundation 0x000000010c3d5578 _CF_forwarding_prep_0 + 120
5 ActionPlusChetech 0x00000001098322a2 -[PersistenceService load:relations:] + 331
6 ActionPlusChetech 0x0000000109830ed7 -[PersistenceService load:relations:error:] + 30
7 ActionPlusChetech 0x00000001097f4bb7 -[MyActionsVC deleteButtonTapped] + 1767
8 ActionPlusChetech 0x00000001097f66be -[MyActionsVC pushMenuItem:] + 526
9 Foundation 0x000000010a611e3a -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 900
10 Foundation 0x000000010a611971 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 132
11 ActionPlusChetech 0x00000001097f750d -[KxMenuItem performAction] + 157
12 ActionPlusChetech 0x00000001097f9940 -[KxMenuView performAction:] + 208
13 UIKit 0x000000010abc9a22 -[UIApplication sendAction:to:from:forEvent:] + 75
14 UIKit 0x000000010acd0e50 -[UIControl _sendActionsForEvents:withEvent:] + 467
15 UIKit 0x000000010acd021f -[UIControl touchesEnded:withEvent:] + 522
16 UIKit 0x000000010af77e80 _UIGestureRecognizerUpdate + 9487
17 UIKit 0x000000010ac0f856 -[UIWindow _sendGesturesForEvent:] + 1041
18 UIKit 0x000000010ac10483 -[UIWindow sendEvent:] + 667
19 UIKit 0x000000010abdcfb1 -[UIApplication sendEvent:] + 246
20 UIKit 0x000000010abea227 _UIApplicationHandleEventFromQueueEvent + 17700
21 UIKit 0x000000010abc523c _UIApplicationHandleEventQueue + 2066
22 CoreFoundation 0x000000010c3abc91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x000000010c3a1b5d __CFRunLoopDoSources0 + 269
24 CoreFoundation 0x000000010c3a1194 __CFRunLoopRun + 868
25 CoreFoundation 0x000000010c3a0bc6 CFRunLoopRunSpecific + 470
26 GraphicsServices 0x000000010ef49a58 GSEventRunModal + 161
27 UIKit 0x000000010abc8580 UIApplicationMain + 1282
28 ActionPlusChetech 0x00000001097ea9e3 main + 115
29 libdyld.dylib 0x000000010d106145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我不太明白这个错误。 -[ActionCreation allKeys]:
和taht有什么关系?并且没有捕获到 Backendless 异常。
谢谢。
好吧,我找到了解决方法。不完全是我想要的,但它有效。因为 UserFavourites 在删除相关操作 object 后有空列,我的应用程序抛出异常,因为它获取的值为空。所以我决定,每次用户加载他的收藏夹时,检查 Action 列是否为空,如果是 - 他们发送请求删除 UserFavourites object。遗憾的是,我无法想出一种方法使这两列像 SQL 一样相互依赖,例如更新时、删除时等等。但是,嘿,它有效!)希望这对遇到此问题的人有所帮助。