Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review diffs between Swift 2 --> preliminary Swift 3 API #4078

Merged
merged 37 commits into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e95cab8
Review diffs between Swift 2 --> preliminary Swift 3 API
Sep 12, 2016
7322bb5
edits to Austin's Swift 3 API review
jpsim Sep 13, 2016
89d021e
byProperty & ofProperty
jpsim Sep 13, 2016
f564858
add a space in @available(_,_,renamed:)
jpsim Sep 13, 2016
719a6ee
rename indexOfObject(for:) to index(matching:)
jpsim Sep 13, 2016
80c1b3a
rename filter(using:) to filter(_:)
jpsim Sep 13, 2016
0ce2458
rename sorted(onProperty:ascending:) to sorted(byProperty:ascending:)
jpsim Sep 13, 2016
d4d2795
rename sorted(with:) to sorted(by:)
jpsim Sep 13, 2016
e1bc4f1
rename minimumValue to min
jpsim Sep 13, 2016
1bd8b72
rename maximumValue to max
jpsim Sep 13, 2016
1d53bfb
rename addNotificationBlock(block:) to addNotificationBlock(_:)
jpsim Sep 13, 2016
166c710
rename removeAllObjects() to removeAll()
jpsim Sep 13, 2016
93e7007
rename removeLastObject() to removeLast()
jpsim Sep 13, 2016
67e8f2c
rename Migration.createObject(ofType:populatedWith:) to create(_:value:)
jpsim Sep 13, 2016
9f79a6a
rename createDynamicObject(ofType:populatedWith:update:) to dynamicCr…
jpsim Sep 13, 2016
15f1b08
rename createObject(ofType:populatedWith:update:) to create(_:value:u…
jpsim Sep 13, 2016
9bd192b
rename Realm.deleteAllObjects() to Realm.deleteAll()
jpsim Sep 13, 2016
e159c3f
rename allObjects(ofType:) to objects(_:)
jpsim Sep 13, 2016
271c143
rename allDynamicObjects(ofType:) to dynamicObjects(_:)
jpsim Sep 13, 2016
c7de28c
rename shouldAutorefresh to autorefresh
jpsim Sep 13, 2016
a052e07
rename writeCopy(toFileURL:encryptionKey:) to writeCopy(toFile:encryp…
jpsim Sep 13, 2016
a700568
consistently call fatalError() in previously named methods
jpsim Sep 13, 2016
60a97cd
update Swift 3 examples
jpsim Sep 13, 2016
6cda901
unlabel write(block:) parameter
jpsim Sep 14, 2016
50139cb
fix Swift 3 SwiftLint violations
jpsim Sep 14, 2016
6c91feb
use ruby instead of jq to parse json from simctl in reset-simulators.sh
jpsim Sep 14, 2016
6a37c83
avoid simctl switch crash and avoid logging pid of springboard
jpsim Sep 14, 2016
e3ae209
fix Error docs, re-add Equatable conformance and ~= operator
jpsim Sep 14, 2016
b673078
nest Notification enum inside Realm
jpsim Sep 14, 2016
9c55b7e
add "Failed to lookup" simulator error to build.sh detection
jpsim Sep 14, 2016
a9571a6
Fixing documentation for Swift 3 APIs
Jul 5, 2016
124a5fa
Remove accidental Swift 2 changes
Sep 14, 2016
b75424a
Update sample projects
Sep 14, 2016
6ab2ee9
Fix issues reported by swiftlint
Sep 14, 2016
2602e6b
Merge pull request #3829 from realm/az-docs
austinzheng Sep 14, 2016
70a1276
remove API .diff
jpsim Sep 15, 2016
1f49449
fix CoreSimulator.log known Xcode error detection
jpsim Sep 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Realm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
02AFB4671A80343600E11938 /* ResultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02AFB4621A80343600E11938 /* ResultsTests.m */; };
02AFB4681A80343600E11938 /* ResultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02AFB4621A80343600E11938 /* ResultsTests.m */; };
02E334C31A5F41C7009F8810 /* DynamicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E81A1FBA1955FE0100FDED82 /* DynamicTests.m */; };
1AB605D31D495927007F53DE /* RealmCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AB605D21D495927007F53DE /* RealmCollection.swift */; };
2973CCF91C175AB400FEA0FA /* fileformat-pre-null.realm in Resources */ = {isa = PBXBuildFile; fileRef = 29B7FDF71C0DE76B0023224E /* fileformat-pre-null.realm */; };
297FBEFB1C19F696009D1118 /* RLMTestCaseUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297FBEFA1C19F696009D1118 /* RLMTestCaseUtils.swift */; };
297FBEFF1C19F844009D1118 /* TestUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 297FBEFE1C19F844009D1118 /* TestUtils.mm */; };
Expand Down Expand Up @@ -243,7 +244,6 @@
5D660FF61BE98D670021E04F /* Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FE81BE98D670021E04F /* Optional.swift */; };
5D660FF71BE98D670021E04F /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FE91BE98D670021E04F /* Property.swift */; };
5D660FF81BE98D670021E04F /* Realm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FEA1BE98D670021E04F /* Realm.swift */; };
5D660FF91BE98D670021E04F /* RealmCollectionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FEB1BE98D670021E04F /* RealmCollectionType.swift */; };
5D660FFA1BE98D670021E04F /* RealmConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FEC1BE98D670021E04F /* RealmConfiguration.swift */; };
5D660FFB1BE98D670021E04F /* Results.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FED1BE98D670021E04F /* Results.swift */; };
5D660FFC1BE98D670021E04F /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D660FEE1BE98D670021E04F /* Schema.swift */; };
Expand Down Expand Up @@ -509,6 +509,7 @@
02B8EF5B19E7048D0045A93D /* RLMCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RLMCollection.h; sourceTree = "<group>"; };
02E334C21A5F3C45009F8810 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
02E334C41A5F4923009F8810 /* RLMRealm_Private.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = RLMRealm_Private.hpp; sourceTree = "<group>"; };
1AB605D21D495927007F53DE /* RealmCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmCollection.swift; sourceTree = "<group>"; };
26F3CA681986CC86004623E1 /* SwiftPropertyTypeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftPropertyTypeTest.swift; sourceTree = "<group>"; };
297FBEFA1C19F696009D1118 /* RLMTestCaseUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RLMTestCaseUtils.swift; sourceTree = "<group>"; };
297FBEFD1C19F844009D1118 /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestUtils.h; path = Realm/Tests/TestUtils.h; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -608,7 +609,6 @@
5D660FE81BE98D670021E04F /* Optional.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Optional.swift; sourceTree = "<group>"; };
5D660FE91BE98D670021E04F /* Property.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Property.swift; sourceTree = "<group>"; };
5D660FEA1BE98D670021E04F /* Realm.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Realm.swift; sourceTree = "<group>"; };
5D660FEB1BE98D670021E04F /* RealmCollectionType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmCollectionType.swift; sourceTree = "<group>"; };
5D660FEC1BE98D670021E04F /* RealmConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmConfiguration.swift; sourceTree = "<group>"; };
5D660FED1BE98D670021E04F /* Results.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Results.swift; sourceTree = "<group>"; };
5D660FEE1BE98D670021E04F /* Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Schema.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -891,7 +891,7 @@
5D660FE81BE98D670021E04F /* Optional.swift */,
5D660FE91BE98D670021E04F /* Property.swift */,
5D660FEA1BE98D670021E04F /* Realm.swift */,
5D660FEB1BE98D670021E04F /* RealmCollectionType.swift */,
1AB605D21D495927007F53DE /* RealmCollection.swift */,
5D660FEC1BE98D670021E04F /* RealmConfiguration.swift */,
5D660FED1BE98D670021E04F /* Results.swift */,
5D660FEE1BE98D670021E04F /* Schema.swift */,
Expand Down Expand Up @@ -1820,10 +1820,10 @@
5D660FF31BE98D670021E04F /* Migration.swift in Sources */,
5D660FF41BE98D670021E04F /* Object.swift in Sources */,
5D660FF51BE98D670021E04F /* ObjectSchema.swift in Sources */,
1AB605D31D495927007F53DE /* RealmCollection.swift in Sources */,
5D660FF61BE98D670021E04F /* Optional.swift in Sources */,
5D660FF71BE98D670021E04F /* Property.swift in Sources */,
5D660FF81BE98D670021E04F /* Realm.swift in Sources */,
5D660FF91BE98D670021E04F /* RealmCollectionType.swift in Sources */,
5D660FFA1BE98D670021E04F /* RealmConfiguration.swift in Sources */,
5D660FFB1BE98D670021E04F /* Results.swift in Sources */,
5D660FFC1BE98D670021E04F /* Schema.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions Realm/RLMObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Creating & Initializing Objects

/**
Initializes an unmanaged instance of a Realm object.
Creates an unmanaged instance of a Realm object.

Call `addObject:` on an `RLMRealm` instance to add an unmanaged object into that Realm.

Expand All @@ -106,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN


/**
Initializes an unmanaged instance of a Realm object.
Creates an unmanaged instance of a Realm object.

Pass in an `NSArray` or `NSDictionary` instance to set the values of the object's properties.

Expand Down Expand Up @@ -413,7 +413,7 @@ NS_ASSUME_NONNULL_BEGIN

@param object The object to compare the receiver to.

@return A Boolean indicating whether the object represents the same object as the receiver.
@return Whether the object represents the same object as the receiver.
*/
- (BOOL)isEqualToObject:(RLMObject *)object;

Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMObjectSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable RLMProperty *)objectForKeyedSubscript:(NSString *)propertyName;

/**
Returns a Boolean value that indicates whether two `RLMObjectSchema` instances are equal.
*/
Returns whether two `RLMObjectSchema` instances are equal.
*/
- (BOOL)isEqualToObjectSchema:(RLMObjectSchema *)objectSchema;

@end
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Methods

/**
Returns a Boolean value that indicates whether a given property object is equal to the receiver.
Returns whether a given property object is equal to the receiver.
*/
- (BOOL)isEqualToProperty:(RLMProperty *)property;

Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
- (RLMObjectSchema *)objectForKeyedSubscript:(NSString *)className;

/**
Returns a Boolean value that indicates whether two `RLMSchema` instances are equivalent.
Returns whether two `RLMSchema` instances are equivalent.
*/
- (BOOL)isEqualToSchema:(RLMSchema *)schema;

Expand Down
94 changes: 58 additions & 36 deletions RealmSwift/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,80 +21,82 @@ import Realm
#if swift(>=3.0)

/**
Enumeration that describes the error codes within the Realm error domain.
Struct that describes the error codes within the Realm error domain.
The values can be used to catch a variety of _recoverable_ errors, especially those
happening when initializing a Realm instance.

let realm: Realm?
do {
realm = Realm()
} catch RealmSwift.Error.incompatibleLockFile {
print("Realm Browser app may be attached to Realm on device?")
}

```swift
let realm: Realm?
do {
realm = Realm()
} catch RealmSwift.Error.incompatibleLockFile {
print("Realm Browser app may be attached to Realm on device?")
}
```
*/
public struct Error {
public enum Code : Int {
/// Error thrown by Realm if no other specific error is returned when a realm is opened.
public enum Code: Int {
/// - see: `Error.fail`
case fail

/// Error thrown by Realm for any I/O related exception scenarios when a realm is opened.
/// - see: `Error.fileAccess`
case fileAccess

/// Error thrown by Realm if the user does not have permission to open or create
/// the specified file in the specified access mode when the realm is opened.
/// - see: `Error.filePermissionDenied`
case filePermissionDenied

/// Error thrown by Realm if the file already exists when a copy should be written.
/// - see: `Error.fileExists`
case fileExists

/// Error thrown by Realm if no file was found when a realm was opened as
/// read-only or if the directory part of the specified path was not found
/// when a copy should be written.
/// - see: `Error.fileNotFound`
case fileNotFound

/// Error thrown by Realm if the database file is currently open in another process which
/// cannot share with the current process due to an architecture mismatch.
/// - see: `Error.incompatibleLockFile`
case incompatibleLockFile

/// Error thrown by Realm if a file format upgrade is required to open the file,
/// but upgrades were explicitly disabled.
/// - see: `Error.fileFormatUpgradeRequired`
case fileFormatUpgradeRequired

/// Error thrown by Realm if there is insufficient available address space.
/// - see: `Error.addressSpaceExhausted`
case addressSpaceExhausted

/// Error thrown by Realm if there is a schema version mismatch, so that a migration is required.
/// - see: `Error.schemaMismatch`
case schemaMismatch
}

/// - see: `Error.Code.fail`
/// Error thrown by Realm if no other specific error is returned when a realm is opened.
public static let fail: Code = .fail

/// - see: `Error.Code.fileAccess`
/// Error thrown by Realm for any I/O related exception scenarios when a realm is opened.
public static let fileAccess: Code = .fileAccess

/// - see: `Error.Code.filePermissionDenied`
/// Error thrown by Realm if the user does not have permission to open or create
/// the specified file in the specified access mode when the realm is opened.
public static let filePermissionDenied: Code = .filePermissionDenied

/// - see: `Error.Code.fileExists`
/// Error thrown by Realm if the file already exists when a copy should be written.
public static let fileExists: Code = .fileExists

/// - see: `Error.Code.fileNotFound`
/// Error thrown by Realm if no file was found when a realm was opened as
/// read-only or if the directory part of the specified path was not found
/// when a copy should be written.
public static let fileNotFound: Code = .fileNotFound

/// - see: `Error.Code.incompatibleLockFile`
/// Error thrown by Realm if the database file is currently open in another process which
/// cannot share with the current process due to an architecture mismatch.
public static let incompatibleLockFile: Code = .incompatibleLockFile

/// - see: `Error.Code.fileFormatUpgradeRequired`
/// Error thrown by Realm if a file format upgrade is required to open the file,
/// but upgrades were explicitly disabled.
public static let fileFormatUpgradeRequired: Code = .fileFormatUpgradeRequired

/// - see: `Error.Code.addressSpaceExhausted`
/// Error thrown by Realm if there is insufficient available address space.
public static let addressSpaceExhausted: Code = .addressSpaceExhausted

/// - see: `Error.Code.schemaMismatch`
/// Error thrown by Realm if there is a schema version mismatch, so that a migration is required.
public static let schemaMismatch: Code = .schemaMismatch

/// :nodoc:
public var code: Code {
let rlmError = _nsError as! RLMError
switch rlmError.code {
Expand All @@ -120,7 +122,7 @@ public struct Error {
}

/// :nodoc:
public var _nsError: NSError
public var _nsError: NSError // swiftlint:disable:this variable_name

/// :nodoc:
public init(_nsError error: NSError) {
Expand All @@ -130,17 +132,37 @@ public struct Error {

/// :nodoc:
// Provide bridging from errors with domain RLMErrorDomain to Error.
extension Error : _BridgedStoredNSError {
extension Error: _BridgedStoredNSError {
/// :nodoc:
public static var _nsErrorDomain = RLMErrorDomain
public static var _nsErrorDomain = RLMErrorDomain // swiftlint:disable:this variable_name
}

/// :nodoc:
extension Error.Code : _ErrorCodeProtocol {
extension Error.Code: _ErrorCodeProtocol {
/// :nodoc:
public typealias _ErrorType = RLMError
}

// MARK: Equatable

extension Error: Equatable {}

/// Returns a Boolean indicating whether the errors are identical.
public func == (lhs: Swift.Error, rhs: Swift.Error) -> Bool { // swiftlint:disable:this valid_docs
return lhs._code == rhs._code
&& lhs._domain == rhs._domain
}

// MARK: Pattern Matching

/**
Pattern matching matching for `Realm.Error`, so that the instances can be used with Swift's
`do { ... } catch { ... }` syntax.
*/
public func ~= (lhs: Error, rhs: Swift.Error) -> Bool { // swiftlint:disable:this valid_docs
return lhs == rhs
}

#else

/**
Expand Down
Loading