Swift 4 imagepickerview error - xcode

errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

You need to ask the permission to access your library
YourPhotoLibrary.requestAuthorization({ (status: YPLAuthorizationStatus) -> Void in()
if YourPhotoLibrary.authorizationStatus() == YPLAuthorizationStatus.authorized {
// Implement your UIImagepicker method here
}
})

enter image description here
this its the code for the image picker

Related

Unable to find object at PDF cross-reference stream location. (abcpdf)

I am getting below error when processing the single page pdf.
May i know why i am getting this error
Doc theSrc = new Doc();
theSrc.Read(e.FullPath); on this line
Unable to find object at PDF cross-reference stream location.
Thanks,
If you use ABCpdf's ExtraChecks feature that would give you the option to either try and get ABCpdf to fix the corruption, or have your own application/site issue a warning that the PDF is corrupt.
Of course there are limits to what ABCpdf can fix - in that case you would still end receiving an error from ABCpdf.
In terms of code, the logic would be something like this:
try
{
doc.Read(inFile);
// No corruption detected
doc.Save("good.pdf");
}
catch
{
try
{
doc.Read(inFile, new XReadOptions { ExtraChecks = true });
// ExtraChecks managed to fix the corruption
doc.Save("fixed.pdf"));
}
catch
{
// ABCpdf could not fix the corruption
}
}

Trying to load Parse PFFiles into UITableView from query

I'm a new, in training, swift programmer and have run into an issue with an app that I'm trying to put together.
I've searched through the forum and have found really helpful information but haven't been able to resolve my issue based on the results unfortunately.
I have an app set up to upload user images as PFFiles to parse but can't seem to have them download to the tableview in my table view controller.
A majority of the code I have tried to implement hasn't caused any errors but also hasn't downloaded the desired images.
I apologize if this is a very basic issue but I've exhausted my researching outlets.
I have the images uploading to a single class called Post and want to be able to pull images based on the current user's ID.
I've tried querying the information but always have an error returned that says that the system was unable to find anything for the query. I'm not sure if there is a better way to upload and classify the information on parse or if I'm not coding the call back correctly. I'm essentially wanting to be able to retrieve the user's uploaded images and descriptions and display them on an "Account" page.
I'm working in Xcode 7.2 in Swift 2.
So there are three things we have to care about:
1. structure of post
It would be better if you store the User in a pointer. A pointer is easier to save and retrieve. (Pointers is a way to present one to many Relations, but in our case this means One to One).
So in the data browser(parse.com) replace the column "userID" with "user" type: Pointer, target class: User.
Then in xCode
post["user"] = PFUser.currentUser()
2. Get All posts of a User
Add this code:
let query = PFQuery(className: "Post")
query.whereKey("user", equalTo: PFUser.currentUser()!)
query.getFirstObjectInBackgroundWithBlock { (obj: PFObject?, err: NSError?) -> Void in
if err != nil{
// DO something with the objets:
myArray = obj
}
}
3. Get the image
Lets say you have a ImageView like imageView
let file: PFFile = post["imageFile"] as! PFFile
file.getDataInBackgroundWithBlock { (data: NSData?, err: NSError?) -> Void in
if data != nil{
imageView.image = UIImage(data: data!)
}
}
Now you're done:)
But just a little thing to improve your code:
You don't need to dismiss the Alert after OK is pressed because if you set style to .Cancel this is automatically done! So change
alert.addAction((UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in
self.dismissViewControllerAnimated(true, completion: nil) })))
to
alert.addAction((UIAlertAction(title: "OK", style: .Cancel, handler: nil)))

Encountering runtime error " attempt to insert nil object "

I am trying to write a simple multiplayers Swift program using Xcode 7 beta 5. I encountered the following error at runtime:
[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack
And then I tried and error and found that this piece of code somehow introduced this error:
func setupMatchHandler() {
/* This function handles invite as sent by other users */
GKMatchmaker.sharedMatchmaker().matchForInvite(GKInvite().self , completionHandler: { (invitedMatch , invitationError) -> Void in
if invitationError != nil {
// error out
print("Game Center error: \(invitationError)")
}
if invitedMatch != nil {
// success
print("invitation received!")
}
})
}
I wonder can any expert here shed light on what went wrong here? Thanks a million!
sam
Maybe a check for (GKInvite().self != nil) could help?
It seems that it's the only thing that you are inserting via matchForInvite is this one

What's the Swift 2.0 equivalent to parse.com's signUpInBackgroundWithBlock:()?

I got the follow error when attempting to build a parse.com project via Xcode 7.0/Swift 2.0:
Is there a work around for this?
What's the Swift 2.0 equiv.?
You can either:
user.signUpInBackgroundWithBlock { (succeeded: ObjCBool, error: NSError?) -> Void in
// do something
}
Or
user.signUpInBackgroundWithBlock { succeeded, error in
// do something
}
--
Note, Xcode can show you the appropriate types. For example, if I start to type and then let code completion show me the method, I see something like:
If I then hit enter and select the block: PFBooleanResultBlock? and hit enter again, I'll see:
That shows me precisely what types those two parameters are.
user.signUpInBackgroundWithBlock {success, error in
if error == nil {
//
}
else{
//
}
}
Above works fine with no errors.

Xcode 7.0 Swift Update Problems

I'm trying to update my project to work with Xcode 7.0 and after updating my Swift projects I'm getting an error that I don't understand on this line.
let jsonData:NSDictionary = NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary
The error is
"Call can throw, but it is not marked with 'try' and the error is not handled"
I'm also getting these two errors in my project files...
"linker command failed with exit code 1 (use -v to see invocation)"
and
"error: cannot parse the debug map for "/Users/MattFiler/Library/Developer/Xcode/DerivedData/ePlanner-cqwzlxqgpwaloubjgnzdlomjkfea/Build/Intermediates/SwiftMigration/ePlanner/Products/Debug-iphonesimulator/ePlannerTests.xctest/ePlannerTests": No such file or directory"
Try this code:
do {
let jsonData = try NSJSONSerialization.JSONObjectWithData(urlData!, options: .MutableContainers ) as! NSDictionary
// Use jsonData here
} catch {
print("Well something happened: \(error)")
}
You'll need the try keyword as NSJSONSerialization.JSONObjectWithData now throws an error if something failed since Swift 2. Throwing functions need to be marked with try or try!.
Also you'll need the do { ... } catch to catch any errors that may occur. This will catch the error and handle it.
You might want to read up on the changes in Swift 2 to understand why this happened. Also the WWDC videos will be very helpful.
You need to try and catch if it throws an error.
do {
let jsonData:NSDictionary = try NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary
//...
}
catch {
}

Resources