iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

Swift: Creating a factory function that takes a class type as a parameter, and outputs a constructor of that class

I’d like to create a factory function that takes in an class type and returns a constructor, so that I can use that constructor to create an instance of that class later. Imagine I have two classes, Apple and Orange, which are both subclasses of Fruit. They need to be initialized with an unknownNumber which […]

UIImage not displayed when added to CALayer in a backgroundtask

in my viewcontroller I have: @IBOutlet var worldmapview: Worldmapview! var eventLayer:CALayer=CALayer(); and some function: func create_picture_layer(pathtopic:String) -> CALayer { let bm=getImage(pathtopic,fBitmapsizeSelected: 100)!; var calayer_for_picture=CALayer(); calayer_for_picture.frame=CGRectMake(100, 100, 100, 100); calayer_for_picture.contents = bm.CGImage; return calayer_for_picture; } func createCircleShape(x:CGFloat,y:CGFloat, size:CGFloat) -> CAShapeLayer { var test2:UIBezierPath=UIBezierPath(ovalInRect: CGRectMake(x – size/2, y – size/2, size, size)); var shapelayer:CAShapeLayer=CAShapeLayer(); shapelayer.backgroundColor=UIColor.clearColor().CGColor; //shapelayer.frame=CGRectMake(0, 0, […]

Unable to compile AWS CustomIdentityProvider on xcode 8 beta 6

I am using Amazon Cognito and Facebook login in an ios app. Up until beta 5 this code from this SO thread worked: class CustomIdentityProvider: NSObject, AWSIdentityProviderManager { var tokens: [NSString: NSString]? init(tokens: [NSString: NSString]) { self.tokens = tokens } @objc func logins() -> AWSTask<NSDictionary> { return AWSTask(result: tokens) // Compile error in beta 6 […]

Fill an array with strings from a txt file

Data.txt contains stuff like thisĀ : “Cat” “Dog” “Mouse” I want to fill an array with strings from that file (dico[0] = “Cat”, dico[1] = “Dog”, aso). I found this, How to call Objective-C's NSArray class method from within Swift? and Read and write data from text file, but when I use this code : let […]

How to increase the single row height without reloading UITableView or individual cells ?

I want to expand the row height and show the content inside. I show my content in view I want when I tap on a cell it should expand like showed in the image below but without reloading the UITableview. What I have tried till now. 1) I tried expanding the view inside but it […]

Rename default rendered headings like “Example” in Swift Markup language

Raw Markup Rendered Markup How do I change the word Example in the “Rendered Markup” to anything I would like?

Swift Custom Cell creating your own Cell with labels

I’ve just started to use Swift as a prorgamming language and i’ve run into a problem with Custom cells. When i try to create custom cells, and then go forward and try to design them the way i need them ( with Style set to Custom ) everything looks good. Now i don’t know how […]

How to use addAttribute in Swift

I’m trying to add links to UITextViews, so I am following the code in this post. The relevant Objective-C code is NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@”This is an example by @marcelofabri_”]; [attributedString addAttribute:NSLinkAttributeName value:@”username://marcelofabri_” range:[[attributedString string] rangeOfString:@”@marcelofabri_”]]; But when I try this in Swift 2 as var attributedString = NSMutableAttributedString(string: “This is an example […]

Firebase sign out not working in Swift

I am using newest Firebase API (3.2.1) and I am using this code to check if user is signed in: override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) if(self.navigationController != nil){ self.navigationController!.setNavigationBarHidden(true, animated: true) } if(FIRAuth.auth() != nil){ self.performSegueWithIdentifier(“loginSuccessSegue”, sender: self) } } In other words if auth object is present I am switching to other controller. […]

Programmatically open NSWindow in another Desktop (Space)

In my OSX Project I want to: identify the Desktop (one of the expose Spaces) where a NSWindow resides; open a NSWindow in a determined Space, not only on current Space. Is there a way to do these simple tasks? Exploring the documentation (NSWindowController, NSWindow, NSScreen) I can’t find anything regarding multiple Desktop Management. Thanks […]