# Instagram Hints (iOS: Objective-C)
### 1. Want to verify data is stored on the Parse server?
Use the [Dashboard](https://guides.codepath.org/android/Configuring-a-Parse-Server#browsing-parse-data) in Back4App. The dashboard allows you to visualize the different collections as tables, as well as edit data directly on the database, without needing to write or run any code.
### 2. Not able to create an App on Back4App due to an Ad-Blocker?
Please try turning off your VPN to finish the process on Back4App. This should resolve the issue!
### 3. When I import in `#import "Parse.h"` this is not found?
Remember from the ParseChat lab that we need to import in the Parse files as so `#import <Parse/Parse.h>`
### 4. My console log has the following error when I am trying to load my images from Parse
`The resource could not be loaded because the App Transport Security policy requires the use of a secure connection`
- **SOLUTION:** In `configuration.server`, try changing the url from `http` to **`https`** (See below snippet)
```
ParseClientConfiguration *config = [ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = @"YOUR_APP_ID"; // <- UPDATE
configuration.clientKey = @"YOUR_CLIENT_KEY"; // <- UPDATE
configuration.server = @"https://parseapi.back4app.com";
}];
[Parse initializeWithConfiguration:config];
```
Also, you'll need to add to your info.plist allow Arbritrary loads. **Right click** on the Info.plist file, and select *Open As* -> *Source Code*. Insert the following...
```
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
```
📖 **To read up on why this is necessary,** you can check out the guide on [App Transport Security](https://guides.codepath.com/ios/App-Transport-Security).
### 5. Are there two error messages in your Post.m file when returning the `PFFileObject`?

There are two hints to look at. The first one being rename the file to its appropriate rename. This should fix the first error. Now the class method `fileWithName:data` isn't found. This is okay because it could be that the method was renamed too right? Why don't we try seeing if autocomplete fixes it. Let's remove the error and see what methods are available. You should see one similar to what we want it to be but renamed. Command + B (rebuild project) -> It should be fixed now! Awesome. :)
### 6. I am not too sure where I want to initialize my UIImagePickerController
Well, let us think of where you want the image picker to appear. The example from CodePath Guide says to use it in the FeedViewController. We already know according to our design specs that we want it to take place in our CreatePostViewController. Let's put it there and work from there.
### 7. I get this weird crash when trying to set the Image from PFImageView
`error: [UIImageView setFile:]: unrecognized selector sent to instance 0x7ff2937a9bd0 on the console`
1. Did you import the pod `'Parse/UI'` and run a `pod install`?
2. Did you set in storyboard the `UIImageView` to be of class `PFImageView`
### 8. Why is my AppDelegate code not working for Persist Logged In User Milestone
With iOS 13, there were changes to how we implement the root view controller window. There is now a file called `SceneDelegate.m`. You should move your code over to the following method in `SceneDelegate.m `
```
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
//insert in the code block that we want for (user != nil)
}
```
Want to learn more about SceneDelegate?
**Apple's Documentation:**
(https://developer.apple.com/documentation/uikit/uiscenedelegate)
### 9. I am able to log out the user but my screen doesn't return to the Login View Controller
With iOS 13, Scene Delegate was introduced. We need to make an instance of the SceneDelegate in order to return to the Login View.
Try out this line and make use of the scene Delegate for setting the `rootViewController` after logout
```
SceneDelegate *myDelegate = (SceneDelegate *)self.view.window.windowScene.delegate;
```
### 10. Are you experiencing a crash in the setPost method?
Does it almost look recursive? Your debugger is overloaded. Are you setting the post like
so?

You cannot use a self assignment when accessing the post object to set its value. You need to do _post. Change it to the following to resolve it:

Please read up on why this is on this document:
(https://stackoverflow.com/questions/21743957/which-should-i-use-self-property-or-property)
### 11. How to access the values on PFObject for `createdAt` or `updateAt`?
These values are set on the Parse end of things and PFObject already contains a property for each (see below image from PFObject.h file provided by the Parse framework)
As such, you can access like any other property...
```
NSDate *createdAt = post.createdAt;
NSDate *updatedAt = post.updatedAt;
```

### 12. Even with resizing the image sometimes I cannot post due to data being too large or it says incorrect data format. I am running out of options
Let us change one method in the Post.m file
```
+ (PFFileObject *)getPFFileFromImage: (UIImage * _Nullable)image {
// check if image is not nil
if (!image) {
return nil;
}
NSData *imageData = UIImageJPEGRepresentation(image, 0.6);
// get image data and check if that is not nil
if (!imageData) {
return nil;
}
return [PFFileObject fileObjectWithName:@"image.jpeg" data:imageData];
}
```
This will compress the data size for your image without needing to resize to such small values like 50 x 50
How I found this is through googling :)
[Check it out here](https://stackoverflow.com/questions/34216927/uploading-image-to-parse-ios-9)
### 13. I am not liking that my header is sticking when I scroll
This is intended behavior and you will have to change the property that affects it in either story board or code. In the CodePath Guides on how to implement a header, please read into the [*Plain vs. Grouped Sections*](https://guides.codepath.org/ios/Table-View-Guide#working-with-sections) documentation.
### 14. Collection View Layout is off, even though I'm calculating the layout in viewDidLoad.
You just need to do all of the layout calculations for sizing the collection view item inside of [viewDidLayoutSubviews](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621398-viewdidlayoutsubviews), another lifecycle method like viewDidLoad that is called after all of the autolayout constraints and view bounds have been updated.
So basically anytime you need to make sure the view has fully been laid out first (like in this case we need to make calculations based on view widths that are determined by autolayout updating)
For instance, if you want the collection view to still have 3 items wide when in landscape, you need to calculate the item size on rotation of device. Since the views will be redrawn because of autolayout, viewDidLayoutSubviews is called and will recalculate the layout for items in your collection view.
```
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
// add in the flow layout code here
}
```