Skip to content

Commit

Permalink
Merge pull request #1021 from magicalpanda/develop
Browse files Browse the repository at this point in the history
Release MagicalRecord 2.3.0
  • Loading branch information
tonyarnold committed Jun 1, 2015
2 parents 7f5142c + 85942b4 commit b205dd5
Show file tree
Hide file tree
Showing 244 changed files with 11,136 additions and 6,360 deletions.
13 changes: 13 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BasedOnStyle: Chromium
AlignTrailingComments: true
BreakBeforeBraces: Allman
ColumnLimit: 0
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerBindsToType: false
SpacesBeforeTrailingComments: 1
TabWidth: 8
UseTab: Never
12 changes: 12 additions & 0 deletions .cocoadocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
additional_guides:
- https://github.com/magicalpanda/MagicalRecord/wiki/Installing-MagicalRecord
- https://github.com/magicalpanda/MagicalRecord/wiki/Getting-Started
- https://github.com/magicalpanda/MagicalRecord/wiki/Working-with-Managed-Object-Contexts
- https://github.com/magicalpanda/MagicalRecord/wiki/Creating-Entities
- https://github.com/magicalpanda/MagicalRecord/wiki/Deleting-Entities
- https://github.com/magicalpanda/MagicalRecord/wiki/Fetching-Entities
- https://github.com/magicalpanda/MagicalRecord/wiki/Saving
- https://github.com/magicalpanda/MagicalRecord/wiki/Usage-Patterns
- https://github.com/magicalpanda/MagicalRecord/wiki/Importing-Data
- https://github.com/magicalpanda/MagicalRecord/wiki/Logging
- https://github.com/magicalpanda/MagicalRecord/wiki/Upgrading-to-MagicalRecord-2.3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ xcuserdata
profile
*.moved-aside

DerivedData
Carthage/Build
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Project Files/Tests/Support/Vendor/Kiwi"]
path = Project Files/Tests/Support/Vendor/Kiwi
url = git://github.com/allending/Kiwi.git
[submodule "Project Files/Tests/Support/Vendor/Expecta"]
path = Project Files/Tests/Support/Vendor/Expecta
url = [email protected]:petejkim/expecta.git
[submodule "Carthage/Checkouts/expecta"]
path = Carthage/Checkouts/expecta
url = https://github.com/specta/expecta.git
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: objective-c
script: Support/Scripts/objc-build-scripts/cibuild
before_install:
- brew update
- if brew outdated | grep -qx xctool; then brew upgrade xctool; fi

osx_image: xcode61
19 changes: 18 additions & 1 deletion Changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## Version 2.3
* Dynamic framework targets are provided for both OS X 10.8+ and iOS 8.0+
* Logging is enabled by default, change the logging level using `+[MagicalRecord setLoggingLevel: MagicalRecordLogLevelOff];`[see the documentation in the wiki](https://github.com/magicalpanda/MagicalRecord/wiki/Logging)
* CocoaLumberjack 2.0 support
* Enabling shorthand category method names can now be done by importing:

```objective-c
#import <MagicalRecord/MagicalRecord.h>
#import <MagicalRecord/MagicalRecord+ShorthandMethods.h>
#import <MagicalRecord/MagicalRecordShorthandMethodAliases.h>
```
Then calling `+[MagicalRecord enableShorthandMethods]`.
[See the documentation in the wiki](https://github.com/magicalpanda/MagicalRecord/wiki/Installing-MagicalRecord#shorthand-category-methods).

* Support for running with Core Data's concurrency debugging checks enabled
* Many, many, many, many fixes to reported issues
## Version 2.2
* Updated examples and fixed errors in README - [Tony Arnold](mailto:[email protected])
* Changes block saves to use child context of rootSavingContext so that large saves do not channel through the default context and block the main thread - r-peck
Expand Down Expand Up @@ -51,7 +68,7 @@
* Added fetchAllWithDelegate: method for NSFRC `c0a1657` - [Saul Mora](mailto:[email protected])
* Fixed Issue #294 - MR_requestAllSortedBy:ascending:inContext: did not use correct context `3656e74` - [Stephen Vanterpool](mailto:[email protected])
* Bumping podspec version `fb81b5b` - [Stephen Vanterpool](mailto:[email protected])
>>>>>>> release/2.1.0

## Version 2.0.7
* Fix small error in README with regard to MR_SHORTHAND - [Maik Gosenshuis](mailto:[email protected])
* Hide intended private cleanUpErrorHandling method - [Saul Mora](mailto:[email protected])
Expand Down
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Thanks for contributing to this project!

To make the process as easy as possible, we've got a few guidelines that we'd appreciate you following:

## Filing Issues

Before you file an issue, please ensure that:

1. **It's a bug or a feature request** — if you're looking for help using MagicalRecord, please ask your question on [Stack Overflow](http://stackoverflow.com/). We monitor the [**MagicalRecord** tag](http://stackoverflow.com/questions/tagged/magicalrecord) so be sure to tag your question so that we see it
1. **Search for an existing issue** — there's a good chance you're not the only one experiencing the problem you've come to tell us about
2. **Include as much information as you can** — if we can't reproduce the problem you've filed, we can't fix it. Include crash logs, exception reports and code if you can.

## We Prefer Pull Requests

If you know exactly how to implement the feature being suggested or fix the bug being reported, please open a pull request instead of an issue. Pull requests are easier than patches or inline code blocks for discussing and merging the changes. Please ensure that you include tests in the Pull Request — we use XCTest with [Expecta](http://github.com/specta/expecta/).

If you can't make the change yourself, please open an issue after making sure that one isn't already logged.

## Contributing Code

Fork this repository, make some great changes (preferably in a branch named for the topic of the changes you're making) and send a pull request!

All code contributions should match our [coding conventions](/magicalpanda/MagicalRecord/wiki/Coding-Conventions).

Thanks for reading the guidelines!
1 change: 1 addition & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "specta/expecta" ~> 1.0
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "specta/expecta" "v1.0.1"
1 change: 1 addition & 0 deletions Carthage/Checkouts/expecta
Submodule expecta added at 9a4e64
13 changes: 13 additions & 0 deletions Docs/Creating-Entities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Creating Entities

To create and insert a new instance of an Entity in the default context, you can use:

```objective-c
Person *myPerson = [Person MR_createEntity];
```

To create and insert an entity into specific context:

```objective-c
Person *myPerson = [Person MR_createEntityInContext:otherContext];
```
26 changes: 0 additions & 26 deletions Docs/DefaultManagedObjectContext.md

This file was deleted.

25 changes: 25 additions & 0 deletions Docs/Deleting-Entities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Deleting Entities

To delete a single entity in the default context:

```objective-c
[myPerson MR_deleteEntity];
```

To delete the entity from a specific context:

```objective-c
[myPerson MR_deleteEntityInContext:otherContext];
```
To truncate all entities from the default context:
```objective-c
[Person MR_truncateAll];
```

To truncate all entities in a specific context:

```objective-c
[Person MR_truncateAllInContext:otherContext];
```
129 changes: 129 additions & 0 deletions Docs/Fetching-Entities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Fetching Entities

#### Basic Finding

Most methods in MagicalRecord return an `NSArray` of results.

As an example, if you have an entity named *Person* related to a *Department* entity (as seen in many of [Apple's Core Data examples](.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdBasics.html#//apple_ref/doc/uid/TP40001650-TP1)), you can retrieve all of the *Person* entities from your persistent store using the following method:

```objective-c
NSArray *people = [Person MR_findAll];
```

To return the same entities sorted by a specific attribute:

```objective-c
NSArray *peopleSorted = [Person MR_findAllSortedBy:@"LastName"
ascending:YES];
```
To return the entities sorted by multiple attributes:
```objective-c
NSArray *peopleSorted = [Person MR_findAllSortedBy:@"LastName,FirstName"
ascending:YES];
```

To return the results sorted by multiple attributes with different values. If you don't provide a value for any attribute, it will default to whatever you've set in your model:

```objective-c
NSArray *peopleSorted = [Person MR_findAllSortedBy:@"LastName:NO,FirstName"
ascending:YES];

// OR

NSArray *peopleSorted = [Person MR_findAllSortedBy:@"LastName,FirstName:YES"
ascending:NO];
```
If you have a unique way of retrieving a single object from your data store (such as an identifier attribute), you can use the following method:
```objective-c
Person *person = [Person MR_findFirstByAttribute:@"FirstName"
withValue:@"Forrest"];
```

#### Advanced Finding

If you want to be more specific with your search, you can use a predicate:

```objective-c
NSPredicate *peopleFilter = [NSPredicate predicateWithFormat:@"Department IN %@", @[dept1, dept2]];
NSArray *people = [Person MR_findAllWithPredicate:peopleFilter];
```
#### Returning an NSFetchRequest
```objective-c
NSPredicate *peopleFilter = [NSPredicate predicateWithFormat:@"Department IN %@", departments];
NSFetchRequest *people = [Person MR_requestAllWithPredicate:peopleFilter];
```

For each of these single line calls, an `NSFetchRequest` and `NSSortDescriptor`s for any sorting criteria are created.

#### Customizing the Request

```objective-c
NSPredicate *peopleFilter = [NSPredicate predicateWithFormat:@"Department IN %@", departments];

NSFetchRequest *peopleRequest = [Person MR_requestAllWithPredicate:peopleFilter];
[peopleRequest setReturnsDistinctResults:NO];
[peopleRequest setReturnPropertiesNamed:@[@"FirstName", @"LastName"]];

NSArray *people = [Person MR_executeFetchRequest:peopleRequest];
```
#### Find the number of entities
You can also perform a count of all entities of a specific type in your persistent store:
```objective-c
NSNumber *count = [Person MR_numberOfEntities];
```

Or, if you're looking for a count of entities based on a predicate or some filter:

```objective-c
NSNumber *count = [Person MR_numberOfEntitiesWithPredicate:...];
```
There are also complementary methods which return `NSUInteger` rather than `NSNumber` instances:
```objective-c
+ (NSUInteger) MR_countOfEntities;
+ (NSUInteger) MR_countOfEntitiesWithContext:(NSManagedObjectContext *)context;
+ (NSUInteger) MR_countOfEntitiesWithPredicate:(NSPredicate *)searchFilter;
+ (NSUInteger) MR_countOfEntitiesWithPredicate:(NSPredicate *)searchFilter
inContext:(NSManagedObjectContext *)context;
```

#### Aggregate Operations

```objective-c
NSNumber *totalCalories = [CTFoodDiaryEntry MR_aggregateOperation:@"sum:"
onAttribute:@"calories"
withPredicate:predicate];

NSNumber *mostCalories = [CTFoodDiaryEntry MR_aggregateOperation:@"max:"
onAttribute:@"calories"
withPredicate:predicate];

NSArray *caloriesByMonth = [CTFoodDiaryEntry MR_aggregateOperation:@"sum:"
onAttribute:@"calories"
withPredicate:predicate
groupBy:@"month"];
```
#### Finding entities in a specific context
All find, fetch, and request methods have an `inContext:` method parameter that allows you to specify which managed object context you'd like to query:
```objective-c
NSArray *peopleFromAnotherContext = [Person MR_findAllInContext:someOtherContext];
Person *personFromContext = [Person MR_findFirstByAttribute:@"lastName"
withValue:@"Gump"
inContext:someOtherContext];
NSUInteger count = [Person MR_numberOfEntitiesWithContext:someOtherContext];
```
Loading

0 comments on commit b205dd5

Please sign in to comment.