Skip to content

Commit 6b80b6c

Browse files
jaysonngJayson Ng
andauthored
Updated examples for Swift (#763)
* Updated Swift usage Updated Swift usage based on parse-community/Parse-SDK-iOS-OSX#1311 * Update cloud-code.md * Added Example on how to abort Hooks and functions Added Example on how to abort Hooks and functions Source: https://github.com/parse-community/parse-server/blob/master/3.0.0.md * Revert "Added Example on how to abort Hooks and functions" This reverts commit 3350d09. * Added Example on how to abort Hooks and functions Added Example on how to abort Hooks and functions Source: https://github.com/parse-community/parse-server/blob/master/3.0.0.md * Revert "Added Example on how to abort Hooks and functions" This reverts commit 3350d09. * Update Swift login snippet to work with current version of Swift Update to change 1. NSError to Error when logging in 2. use updated function name * Updated currentUser() to current() Updated currentUser() to current() when checking for currentuser * Update login / logout Update to swift and ObjC login section to change currentUser() to current() * Revert "Update login / logout" This reverts commit 3299b67. * updated for latest version of Parse. updated for latest version of Parse. * few swift updates i found that were outdated Co-authored-by: Jayson Ng <[email protected]>
1 parent 1921dfe commit 6b80b6c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

_includes/common/security.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ PFUser *user = [PFUser currentUser];
7979
user.ACL = [PFACL ACLWithUser:user];
8080
```
8181
```swift
82-
if let user = PFUser.currentUser() {
82+
if let user = PFUser.current() {
8383
user.ACL = PFACL(user: user)
8484
}
8585
```
@@ -136,7 +136,7 @@ To make it super easy to create user-private ACLs for every object, we have a wa
136136
[PFACL setDefaultACL:[PFACL ACL] withAccessForCurrentUser:YES];
137137
```
138138
```swift
139-
PFACL.setDefaultACL(PFACL(), withAccessForCurrentUser: true)
139+
PFACL.setDefault(PFACL(), withAccessForCurrentUser: true)
140140
```
141141
</div>
142142
{% endif %}
@@ -189,7 +189,7 @@ privateData.ACL = [PFACL ACLWithUser:[PFUser currentUser]];
189189
[[PFUser currentUser] setObject:privateData forKey:@"privateData"];
190190
```
191191
```swift
192-
if let currentUser = PFUser.currentUser() {
192+
if let currentUser = PFUser.current() {
193193
let privateData = PFObject(className: "PrivateUserData")
194194
privateData.ACL = PFACL(user: currentUser)
195195
privateData.setObject("555-5309", forKey: "phoneNumber")
@@ -262,9 +262,9 @@ PFACL *acl = [PFACL ACL];
262262
```
263263
```swift
264264
let acl = PFACL()
265-
acl.setPublicReadAccess(true)
265+
acl.hasPublicReadAccess = true
266266
if let currentUser = PFUser.currentUser() {
267-
acl.setWriteAccess(true, forUser: currentUser)
267+
acl.setWriteAccess(true, for: currentUser)
268268
}
269269
```
270270
</div>
@@ -314,7 +314,7 @@ $acl->setWriteAccess(ParseUser::getCurrentUser(), true);
314314
```
315315
{% endif %}
316316

317-
Sometimes it's inconvenient to manage permissions on a per-user basis, and you want to have groups of users who get treated the same (like a set of admins with special powers). Roles are are a special kind of object that let you create a group of users that can all be assigned to the ACL. The best thing about roles is that you can add and remove users from a role without having to update every single object that is restricted to that role. To create an object that is writeable only by admins:
317+
Sometimes it's inconvenient to manage permissions on a per-user basis, and you want to have groups of users who get treated the same (like a set of admins with special powers). Roles are a special kind of object that let you create a group of users that can all be assigned to the ACL. The best thing about roles is that you can add and remove users from a role without having to update every single object that is restricted to that role. To create an object that is writeable only by admins:
318318

319319
{% if page.language == "objective_c-swift" %}
320320
<div class="language-toggle" markdown="1">

_includes/ios/users.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func myMethod() {
4848
// other fields can be set just like with PFObject
4949
user["phone"] = "415-392-0202"
5050

51-
user.signUpInBackgroundWithBlock {
52-
(succeeded: Bool, error: NSError?) -> Void in
51+
user.signUpInBackground {
52+
(succeeded: Bool, error: Error?) -> Void in
5353
if let error = error {
54-
let errorString = error.userInfo["error"] as? NSString
54+
let errorString = error.localizedDescription
5555
// Show the errorString somewhere and let the user try again.
5656
} else {
5757
// Hooray! Let them use the app now.
@@ -416,7 +416,7 @@ To kick off the password reset flow, ask the user for their email address, and c
416416
[PFUser requestPasswordResetForEmailInBackground:@"[email protected]"];
417417
```
418418
```swift
419-
PFUser.requestPasswordResetForEmailInBackground("[email protected]")
419+
PFUser.requestPasswordResetForEmail(inBackground:"[email protected]")
420420
```
421421
</div>
422422

0 commit comments

Comments
 (0)