code=exc_i386_invop subcode=0x0 nib xcode7.2 - ios

I have created a custom cell through nib and applied some constraints on it. Moving forward, I replaced that nib file with some old state of nib by replacing it in finder. Also all outlets and constraints are removed; Means, there is no any constraints and outlets now present.
After running the code, exception and crash is coming.
code=exc_i386_invop subcode=0x0
Afterwards, i removed all the things in nib file; Now nib is entirely empty. I have double checked, no any outlet attached with that nib.
I am sure, something happen with copying and pasting the nib; Now i have to remove the nib file, and create new nib file then it will work again.
Please let me know if anyone also faced this type of problem?

I have found the solution; As i copy and past the content of xib file from one xib to another xib, there is possibility that in next xib's .swift file contains any #IBOutlet that is not present in copied xib file;
For Example:
#IBOutlet var profilePicture: UIImageView!
#IBOutlet var coverPicture: UIImageView!
#IBOutlet var personName: UILabel!
#IBOutlet var jobTitle: UILabel!
#IBOutlet var currentLocation: UILabel!
There all outlets are non-optionals; So if anyone of them not linked in xib file, then at run time app will crash; So have to double check for IBOutlets; So that the outlets which are not used in .swift file, you need to remove them or make them optional with '?' keyword.

Related

Indexing issues with Xcode 8

For some reason, defined outlets in XCode are not appearing in the right-click menu when I try to associate an object in the view with the outlet. For example:
import UIKit
class EditProfileTableViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
#IBOutlet var photoImageView: UIImageView!
#IBOutlet var businessName: UITextField!
#IBOutlet var businessAddress: UITextField!
#IBOutlet var businessHours: UITextField!
#IBOutlet var businessPhoneNumber: UITextField!
#IBOutlet var businessWebsite: UITextField!
...
As seen in the above example, there are many text fields that were defined, but if I try to associate the outlets to the objects in the view, it doesn't even appear in the right click menu here. (The photoImageView outlet was defined about a month ago, but for some reason the new outlets aren't working.)
In fact, the Identity Inspector shows nothing in the Class dropdown menu:
I believe there was some type of hiccup syncing files on Dropbox and something was accidentally deleted, and now I'm not quite sure how to fix this. I've tried:
Cleaning and re-building the project
Removing the project directories from "~/Library/Developer/Xcode/DerivedData" to force Xcode to re-index (and restarted Xcode)
and still nothing. I'd really hate to completely wipe my project and start from scratch, so I'm hoping to be able to get this resolved. I doubt it's anything as far as in the application that's done incorrectly since this worked before, but I'm not 100%.
If I copy my project folder to another location (let's say from DropBox to my Desktop), everything works perfectly fine! Confusing!
Any suggestions would be greatly appreciated.
There are two possible situation out of my head.
Double check that your view controller on storyboard is really connected to your code. Set a break point in viewDidLoad function to validate this.
If the connection is correct, then the cause of this issue could be that your outlet code is somehow disconnected from the elements on your storyboard. To fix this, do right click on your view controller like your second screen shot. In Outlets section, delete all connections by clicking on the little cross sigh in the middle. Then reconnect by ctr drag the element to your outlets in view controllers.

Property with type 'UIBarButtonItem!' cannot override a property with type 'UIResponder?' after changing to Swift 3

I have two buttons declared here:
#IBOutlet var previous: UIBarButtonItem!
// No error even though its nearly identical
#IBOutlet var next: UIBarButtonItem!
// contains error Property 'next' with type 'UIBarButtonItem!'
// cannot override a property with type 'UIResponder?'
This worked fine until I upgraded to swift 3. I tried removing all references and button, relinking using the editor with no luck
You need to change the name of your outlet (and it's connection in your storyboard) from next to nextItem, as the Swift 3 API's forUIResponder now have a next property.

Connect new outlet from storyboard is always nil

I'm trying to connect new outlet from storyboard to UIViewController (by dragging), the outlet created as follow:
#IBOutle var button2: UIButton!
without "weak" key,
in runtime, the outlet is nil, even if I add the "weak" key by myself and reconnect it again.
Its append in all the viewControllers in my project, only in one project.
(there are old outlets that work, the issue is only in new outlets create)
I tried to delete the drivedData.
The files exist in the Target, in Compile Resources
I'm using Xcode 8 yet.
any answer?
Finally i figure it out , i delete the Storyboard by removing reference,
and then reconnected it.
I guess that something append to the file reference, so the file did not respond to any changes.
10x 4 help!

Container View - No Outlet Possible

I have a ViewController with a ScrollView in it, which has 2 ContainerViews in it. Now, every ContainerView loads a ViewController.
And in this ViewControllers (SubController from the ContainerViews) its impossible to do Outlets.
I get the little circles at the outlets, so the reference exists, but setting the text of a label for example, always results in the following error:
fatal error: unexpectedly found nil while unwrapping an Optional value
I've done the connection 10 times, with all possible names. Restarted xcode multiple times, still not working.
This answer could help: https://stackoverflow.com/a/28479934/2414069
EDIT: (below code is pseudo, everything is in the place it should..)
#IBOutlet weak var pinInfo_name: UILabel!
#IBOutlet weak var pinInfo_address: UITextView!
#IBOutlet weak var pinInfo_comment: UITextView!
self.pinInfo_name.text = defaults.stringForKey("activePin_name")!
self.pinInfo_address.text = defaults.stringForKey("activePin_address")!
self.pinInfo_comment.text = defaults.stringForKey("activePin_comment")!
SOULUTION:
Ok I slept about it, and found my error within 10 minutes: I wanted to change the .text properties from a object I created in another ViewController. I still have no Idea how to do that, buts thats a story for another time.
tl dr
Access right
As the link in your question points out, having multiple view controllers in your storyboard with the same class could cause this. Did you check that:
The child view controllers do not have the same class as each other
The child view controllers do not have the same class as the parent view controller
I made a test project and the I could connect the outlets of the UILabels in the child view controller to their respective UIViewController subclasses without any problem.
Here's my example:

Can't connect TableView #IBOutlet to ViewController in Swift 2

I am building an app in which I want to press an annotation button and a TableViewCell will pop up. The problem is, when I try to create an #IBOutlet with control+ drag, to ViewController, it doesn't work. Also if I simply write the code : #IBOutlet weak var tableView: UITableView! on ViewController, when I run the app and hit the button, it crashes. What should I do?
Thanks in advance!
Chris,refer this image.Maybe it helps.
Make sure the given class in the Identity Inspector matches your class name.

Resources