Swift. Can't Connect my Button to GIDSignIn Button in my Class - ios

I am new to the swift. I follow the google tutorial to use Firebase Google OAuth method.
https://firebase.google.com/docs/auth/ios/google-signin
At step 9, I try to connect a custom button by control + drag to my property :
#IBOutlet weak var signInButton: GIDSignInButton!
But Xcode doesn't select it. It shows a pop up to create a new property. Though I have two others button: UIButton and when I try to connect to them, it works.
Could help me with that? It might miss some elements of my problem, so don't hesitate to ask.
Thank you!

Drag from the empty circle on the left of #IBOutlet to your button (not vice versa)

Related

iboutlet & ibaction connection errors

In my Xcode project I'm facing this issue with my IBOutlet and was wondering if anyone could help this troubleshoot.
its whenever I connect it only shows acton it also won't let me click and drag. Is there any way to fix this issue?
#IBOutlet weak var emailTextField: UITextField!
as you can see the connection won't allow me to change its grayed out.
How to fix this frustrating issue?
The objective is a bit unclear, however it seems you are trying to connect an IBOutlet in code with an exit IBAction in the IDE. This is not going to be possible. Either create a proper IBAction function for use with a manual unwind segue, make a normal action method, or simply point a proper object at the IBOutlet as needed. To review how to do this properly just use the Help > Xcode Help in Xcode to configure this correctly. For more info on making an unwind segue check out the technote.

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.

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.

Unable to access custom tableviewcell button properties in Swift

Working on my first iOS app. I have created nib and a custom tableview cell. The cell has buttons and labels. I am able to access the labels but for some reason I cannot get the properties of the buttons such as set title, for example. I only have access to the following:
cell.followUserButton(sender: AnyObject)
Why can't I just go
cell.followUserButton.setTitle = "Unfollow"
I looked online quite a bit. Couldn't find anything. Any help is appreciated. Thanks.
You have to write setTitle() this way:
cell.followUserButton.setTitle("Sample Title", forState: .Normal)
Btw setTitle() is function not a property.
Solved my own problem. I was setting it as only an IBAction. If you want to change the attributes then you also have to make the button an outlet too!
#IBOutlet weak var followUser: UIButton!
As you may already know, you can do this within the storyboard. Works perfectly now.

Outlet collection in Swift causes Error 254

I'm working on Stanford's Matchismo game and I'm trying to create an array of buttons that I can reference in the controller. it's a card game, each card a button.
I drag/drop a UIButton to the controller and then set it up in an outlet collection. Not only does it set it up but lets me link multiple outlets to that collection. So far so good.
However when I compile my code (target iOS 7.1) I get a 254 error. I've identified that it's the outlet collection that causes the error.
class MainController: UIViewController{
let cardDeck = PlayingCardDeck()
#IBOutlet var cardButtons: UIButton[]
}
When I replace the UIButton[] mention with NSArray the compiler loads without error. But this is not at all what the exercise is all about - I'm expecting Swift to register the outlets that have been linked to the UIButton[] array and allow me to manipulate that array.
That is, as far as I can tell, the expectation set by the "link to outlet collection" feature in XCode6 Beta 3.
I uploaded a screenshot of the error report. Apparently this has to do with unwrapping the weakly referenced optional array. This is beyond my powers to fix on my own.
You need to define it properly, currently your declaration is not proper -
If you are defining outlet of array of buttons then use -
#IBOutlet var cardButtons: Array <UIButton>
If you are defining outlet of single button then use -
#IBOutlet var cardButton: UIButton
This is still not working in Xcode seed 6.3, however for possible workaround check this link - link
Try This
#IBOutlet var cardButtons: Array<UIButton>

Resources