ios-queryable is an implementation of IQueryable/IEnumerable for Core Data

Related tags

Layout ios-queryable
Overview

#ios-queryable is an Objective-C category that provides IQueryable and IEnumerable-like functionality to Core Data.

Tired of writing boilerplate Core Data code? Can't live without LINQ? ios-queryable is for you!

It supports query composition and deferred execution, and implements a subset of IEnumerable's methods, including where, take, skip, orderBy, first/firstOrDefault, single/singleOrDefault, count, any, and all.

It lets you write code like this:

NSArray* widgets = [[[[[self.managedObjectContext ofType:@"Widget"]
			where:@"Type == 'abc'"]
			orderBy:@"createddate"]
			take:5]
			toArray];

instead of like this:

NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription* entity = [NSEntityDescription
                               entityForName:@"Widget" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
 
NSPredicate* predicate = [NSPredicate predicateWithFormat: @"type == 'abc'"];
[fetchRequest setPredicate:predicate];
 
NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc]
                                    initWithKey:@"createddate" ascending:YES];
 
NSArray* sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
 
[fetchRequest setFetchLimit:5];   
NSError* error;
NSArray* widgets = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

It also supports the NSFastEnumeration protocol, allowing for easy use in foreach loops:

foreach(Widget* widget in [self.managedObjectContext ofType:@"Widget"])
{
	// Do widgety stuff
}

#Usage To use ios-queryable, simply copy NSManagedObjectContext+IQueryable.h and NSManagedObjectContext+IQueryable.m into your project folder. Then, simply include the header file, and start writing your queries!

For examples, check out the tests in the tests project.

You might also like...
VidyoPlatform Basic CustomLayouts Reference App for iOS (Swift)VidyoPlatform Basic CustomLayouts Reference App for iOS (Swift)

VidyoPlatform Basic CustomLayouts Reference App for iOS (Swift) VidyoPlatform reference application highlighting how to integrate video chat into a na

Olvid-ios - Olvid client application for iOS

Olvid Olvid is a private and secure end-to-end encrypted messenger. Contrary to

IOS-PokemonQuizApp - Assignment to make a responsive iOS app. App has to connect with an external API

iOS-PokemonQuizApp Assignment to make a responsive iOS app. App has to connect with an external API. The Project The idea of the project is to make a

Flixtor-iOS - iOS streaming app inspired by Netflix that allows you to watch any film and series
Flixtor-iOS - iOS streaming app inspired by Netflix that allows you to watch any film and series

Flixtor-iOS iOS streaming app inspired by Netflix that allows you to watch any f

IOSAnimationSample-master - An iOS Animation playground to exercise different iOS Animations
IOSAnimationSample-master - An iOS Animation playground to exercise different iOS Animations

iOS Animation Sample This app is an iOS Animation playground to exercise differe

 BrickKit is a delightful layout library for iOS and tvOS. It is written entirely in Swift!
BrickKit is a delightful layout library for iOS and tvOS. It is written entirely in Swift!

BrickKit is a delightful layout library for iOS and tvOS. It is written entirely in Swift! Deprecated BrickKit is being phased out at Wayfair, and the

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
LayoutKit is a fast view layout library for iOS, macOS, and tvOS.

๐Ÿšจ UNMAINTAINED ๐Ÿšจ This project is no longer used by LinkedIn and is currently unmaintained. LayoutKit is a fast view layout library for iOS, macOS, a

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

Simple static table views for iOS in Swift.
Simple static table views for iOS in Swift.

Simple static table views for iOS in Swift. Static's goal is to separate model data from presentation. Rows and Sections are your โ€œview modelsโ€ for yo

Comments
  • countByEnumeratingWithState:objects:count: crashes if managed context changes while enumerated

    countByEnumeratingWithState:objects:count: crashes if managed context changes while enumerated

    The method in discussion executes a fetch request (via its toArray) each time the runtime asks for a batch of objects to enumerate through. And if the managed object contents change between fetch requests, it generates a crash as the toArray contents are not the same between invocations.

    opened by cristik 5
  • FirstOrDefault with condition throws exception on line #139 - Bad Access

    FirstOrDefault with condition throws exception on line #139 - Bad Access

    As I understand it, these two code snippets should be identical in behaviour.

    [[myQueryable where:@"someId = %@", someId] firstOrDefault]; and [myQueryable firstOrDefault:@"someId = %@", someId];

    However the first works a treat, the second dies in the where [NSPredicate predicateWithFormat:condition arguments:args];

    opened by Codeglee 1
  • Semantic Versioning

    Semantic Versioning

    Iโ€™ve recently added IOSQueryable to the CocoaPods package manager repo.

    CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

    However, IOSQueryable doesn't have any version tags. Iโ€™ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

    Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

    In case you didnโ€™t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

    $ git tag -a 1.0.0 -m "Tag release 1.0.0"
    $ git push --tags
    
    opened by orta 1
  • Unrecognized Selector count sent to an NSNumber

    Unrecognized Selector count sent to an NSNumber

    While trying to query an average value during an NSManagedObject's awakeFromFetch and awakeFromInsert, I'm getting this error:

    2015-08-10 22:07:10.077 PropertyHunter[29805:971191] -[NSDecimalNumber count]: unrecognized selector sent to instance 0x608000431260

    The line of code:

    [[[sharedContext ofType:@"Store"] where:@"location.zipcode = %@", self.zipcode] average:@"visits"];

    I'm using this in a Mac OS X app. Any idea why this happens?

    opened by EddyBorja 2
Owner
Marty Dill
Marty Dill
IOS-App4 - Core Data add new data and update data

iOS-App4 Core Data add new data and update data.

null 0 Jan 8, 2022
FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.

FlexLayout adds a nice Swift interface to the highly optimized Yoga flexbox implementation. Concise, intuitive & chainable syntax. Flexbox is an incre

layoutBox 1.7k Dec 30, 2022
sample project for `UICollectionViewLayout` implementation

collection-view-layout-pattern-sample UICollectionViewLayout implementation pattern. About This project is introduced in iOSDC Japan 2021. sample code

Toshiki Takezawa 13 Nov 3, 2021
Fancy Swift implementation of the Visual Format Language (experimental and doesn't work with the recent version of Swift)

VFLToolbox Autolayout is awesome! VFL a.k.a Visual Format Language is even more awesome because it allows you to shorten constraints setting code. The

0xc010d 144 Jun 29, 2022
VerticalFlowLayout - This implementation is built using a UICollectionView and a custom flowLayout.

VerticalFlowLayout This implementation is built using a UICollectionView and a custom flowLayout. Table of contents Requirements Installation CocoaPod

Alexander Sibirtsev 2 Apr 19, 2022
A iOS SwiftUI framework for displaying data from an api inside a List.

FeedListKit FeedListKit is a high level framework for representing data from an Api inside a SwiftUi List. It automatically handles refreshing and loa

Knoggl 3 Nov 2, 2022
API Calling - Made an app in swift that gets data from Randomuser api and uses it in UITableView

API_Calling Made an app in swift that gets data from Randomuser api and uses it

Arnav Chhokra 1 Feb 4, 2022
UIViews that update themselves when your data changes, like React.

StateView is a UIView substitute that automatically updates itself when data changes. Contents: Overview What's it like? Sample apps How does it work?

Sahand Nayebaziz 491 Sep 9, 2022
App in Swift that shows a picture of an astronomical phenomenon and a brief explanation of it everyday, allowing you to save that data or share it on a social network.

DailyUniverse ??โ€โ™‚๏ธ ?? App under construction iOS App that shows a picture of an astronomical phenomenon and a brief explanation of it everyday. Daily

Pedro Muniz 5 Nov 3, 2022
Om๐Ÿ‘€iOS - ์˜ค๋Š˜์€ ๋ฌด์Šจ iOS?!

์˜ค๋ฌด๋ Œ Omoolen, ์ฝ˜ํƒํŠธ ๋ Œ์ฆˆ ์‚ฌ์šฉ์ž๋ฅผ ์œ„ํ•œ ๋งž์ถค ๋ Œ์ฆˆ ์ถ”์ฒœ ๋ฐ ์˜คํ”„๋ผ์ธ ํ”ฝ์—… ์˜ˆ์•ฝ ์„œ๋น„์Šค SOPT 28th APPJAM ํ”„๋กœ์ ํŠธ ๊ธฐ๊ฐ„: 2021.06.26 ~ 2021.07.17 ์†Œ๊ฐœ ํŒ€์› ์†Œ๊ฐœ ๊น€์†Œ์—ฐ ๊น€ํ˜„๊ทœ ์ž„๊ฒฝ์ง„ Development Environment a

Team Omoolen 19 Dec 28, 2022