@eskimo
Thank you very much! Here is what I have now:
Last Exception Backtrace:
0 CoreFoundation 0x1aaf29288 __exceptionPreprocess + 220
1 libobjc.A.dylib 0x1c3c23744 objc_exception_throw + 60
2 Realm (anonymous namespace)::managedSetter(RLMProperty*, char const*) (in Realm) (RLMAccessor.mm:383)
3 Realm +[RLMObjectSchema schemaForObjectClass:] (in Realm) (RLMObjectSchema.mm:140)
4 RealmSwift Realm.add(_:update:) (in RealmSwift) (Realm.swift:438)
5 AppName one-time initialization function for pictureObjectIDandWordArray (in AppName) (TestWords.swift:179)
6 AppName specialized TopVideoCard.isChosen.willset (in AppName) (TopVideoCard.swift:91)
7 AppName one-time initialization function for testCategories2 (in AppName) (TestWords.swift:344)
8 RealmSwift Realm.write<A>(withoutNotifying:_:) (in RealmSwift) (Realm.swift:255)
9 AppName one-time initialization function for pictureObjectIDandWordArray (in AppName) (<compiler-generated>:0)
10 AppName AppDelegate.application(_:didFinishLaunchingWithOptions:) (in AppName) (AppDelegate.swift:257)
11 AppName AppDelegate.application(_:didFinishLaunchingWithOptions:) (in AppName) (<compiler-generated>:0)
12 UIKitCore 0x1ad62f72c -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 340
13 UIKitCore 0x1ad816564 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3572
14 UIKitCore 0x1ad7ff118 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1180
15 UIKitCore 0x1ad65cd34 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 152
16 UIKitCore 0x1ad4b73b4 _UIScenePerformActionsWithLifecycleActionMask + 104
17 UIKitCore 0x1ad5e1d90 __101-[_UISceneLifecycleMultiplexer
Here is parts of those files (with line number after //:
RLMAccessor:
id managedSetter(RLMProperty *prop, const char *type) {
if (prop.array && prop.type != RLMPropertyTypeLinkingObjects) {
return makeSetter<id<NSFastEnumeration>>(prop);
}
bool boxed = prop.optional || *type == '@';
switch (prop.type) {
case RLMPropertyTypeInt:
if (boxed) {
return makeSetter<NSNumber<RLMInt> *>(prop);
}
switch (*type) {
case 'c': return makeSetter<char, long long>(prop);
case 's': return makeSetter<short, long long>(prop);
case 'i': return makeSetter<int, long long>(prop);
case 'l': return makeSetter<long, long long>(prop);
case 'q': return makeSetter<long long>(prop);
default:
@throw RLMException(@"Unexpected property type for Objective-C type code");
}
case RLMPropertyTypeFloat:
return boxed ? makeSetter<NSNumber<RLMFloat> *>(prop) : makeSetter<float>(prop); // line 383
case RLMPropertyTypeDouble:
return boxed ? makeSetter<NSNumber<RLMDouble> *>(prop) : makeSetter<double>(prop);
case RLMPropertyTypeBool:
return boxed ? makeSetter<NSNumber<RLMBool> *>(prop) : makeSetter<BOOL, bool>(prop);
case RLMPropertyTypeString: return makeSetter<NSString *>(prop);
case RLMPropertyTypeDate: return makeSetter<NSDate *>(prop);
case RLMPropertyTypeData: return makeSetter<NSData *>(prop);
case RLMPropertyTypeAny: return nil;
case RLMPropertyTypeLinkingObjects: return nil;
case RLMPropertyTypeObject: return makeSetter<RLMObjectBase *>(prop);
case RLMPropertyTypeObjectId: return makeSetter<RLMObjectId *>(prop);
case RLMPropertyTypeDecimal128: return makeSetter<RLMDecimal128 *>(prop);
}
}
RLMObjectSchema:
if (allProperties.count != [NSSet setWithArray:[allProperties valueForKey:@"name"]].count) {
NSCountedSet *countedPropertyNames = [NSCountedSet setWithArray:[allProperties valueForKey:@"name"]];
NSArray *duplicatePropertyNames = [countedPropertyNames filteredSetUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id object, NSDictionary *) { // line 140
return [countedPropertyNames countForObject:object] > 1;
}]].allObjects;
if (duplicatePropertyNames.count == 1) {
@throw RLMException(@"Property '%@' is declared multiple times in the class hierarchy of '%@'", duplicatePropertyNames.firstObject, className);
} else {
@throw RLMException(@"Object '%@' has properties that are declared multiple times in its class hierarchy: '%@'", className, [duplicatePropertyNames componentsJoinedByString:@"', '"]);
}
}
Realm.swift
public func add(_ object: Object, update: UpdatePolicy = .error) {
if update != .error && object.objectSchema.primaryKeyProperty == nil {
throwRealmException("'\(object.objectSchema.className)' does not have a primary key and can not be updated")
}
// remove any observers still attached to the Realm.
// if not using SwiftUI, this is a noop
if #available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) {
SwiftUIKVO.removeObservers(object: object)
}
RLMAddObjectToRealm(object, rlmRealm, RLMUpdatePolicy(rawValue: UInt(update.rawValue))!)
} // line 438
Thank you very much for your help!