Latest 0.1.1
Homepage https://github.com/CFKevinRef/KCOrderedAccessorFix
License Unlicense This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to

Frameworks CoreData
Authors

Fixes "CoreDataGeneratedAccessors" for ordered, to-many relationships. At the time of this writing, accessors are being auto-generated in the regular unordered KVC accessor pattern (NSSet-like), causing runtime crashes. Besides unrecognized selectors for most of the accessors, the following are common exceptions:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSOrderedSet intersectsSet:]: set argument is not an NSSet'
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet isSubsetOfSet:]: set argument is not an NSSet'
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSOrderedSet isSubsetOfSet:]: set argument is not an NSSet'

The simplest use of this category is calling kc_generateOrderedSetAccessors when first initializing your model:

_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
[_managedObjectModel kc_generateOrderedSetAccessors];

The fix generates the following methods on its entities’s classes for each ordered relationship:

- (void)insertObject:(NSManagedObject *)value in<Key>AtIndex:(NSUInteger)idx;
- (void)removeObjectFrom<Key>AtIndex:(NSUInteger)idx;
- (void)insert<Key>:(NSArray *)value atIndexes:(NSIndexSet *)indexes;
- (void)remove<Key>AtIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectIn<Key>AtIndex:(NSUInteger)idx withObject:(NSManagedObject *)value;
- (void)replace<Key>AtIndexes:(NSIndexSet *)indexes with<Key>:(NSArray *)values;
- (void)add<Key>Object:(NSManagedObject *)value;
- (void)remove<Key>Object:(NSManagedObject *)value;
- (void)add<Key>:(NSOrderedSet *)values;
- (void)remove<Key>:(NSOrderedSet *)values;

More fine-grained applications of these KVC methods are available through kc_generateOrderedSetAccessorsForEntity: and kc_generateOrderedSetAccessorsForRelationship:.

Calling the generated methods does not result in setting the underlying property with a new ordered set, as done by some other fixes for this issue. Instead, each method produces the appropriate KVO notifications for an ordered to-many relationship and uses the efficient dynamically-generated primitive accessors.

This category uses ARC. For use in a manual reference counting project, add the -fobjc-arc flag to "Compiler Flags" in Build Phases –> Compile Sources for NSManagedObjectModel+KCOrderedAccessorFix.m.

Latest podspec

{
    "name": "KCOrderedAccessorFix",
    "version": "0.1.1",
    "summary": "Fixes "CoreDataGeneratedAccessors" for ordered, to-many relationships.",
    "description": "KVC accessors for ordered, to-many relationships (NSOrderedSet) defined in Xcode's "CoreDataGeneratedAccessors" category are being auto-generated in the regular unordered KVC accessor pattern (NSSet-like), causing runtime crashes. This library intelligently overrides the broken implementation on the appropriate NSManagedObject subclasses.",
    "homepage": "https://github.com/CFKevinRef/KCOrderedAccessorFix",
    "license": {
        "type": "Unlicense",
        "text": "This is free and unencumbered software released into the public domain.nnAnyone is free to copy, modify, publish, use, compile, sell, orndistribute this software, either in source code form or as a compilednbinary, for any purpose, commercial or non-commercial, and by anynmeans.nnIn jurisdictions that recognize copyright laws, the author or authorsnof this software dedicate any and all copyright interest in thensoftware to the public domain. We make this dedication for the benefitnof the public at large and to the detriment of our heirs andnsuccessors. We intend this dedication to be an overt act ofnrelinquishment in perpetuity of all present and future rights to thisnsoftware under copyright law.nnTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFnMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES ORnOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE ORnOTHER DEALINGS IN THE SOFTWARE.nnFor more information, please refer to n"
    },
    "authors": {
        "Kevin Cassidy Jr": "[email protected]"
    },
    "source": {
        "git": "https://github.com/CFKevinRef/KCOrderedAccessorFix.git",
        "tag": "0.1.1"
    },
    "requires_arc": true,
    "public_header_files": "NSManagedObjectModel+KCOrderedAccessorFix.h",
    "source_files": "NSManagedObjectModel+KCOrderedAccessorFix.{h,m}",
    "frameworks": "CoreData"
}

Pin It on Pinterest

Share This