user3777933
user3777933

Reputation: 424

Trouble importing foundation into swift... Xcode 6 beta

I am brand new to Xcode. Thank you for reading this.

I'm simply attempting to get used to the language, so I'm simply messing with code by importing Foundation and creating a simple NSRect. However, I'm getting an error when I try to create NSRect.

Here's the code:

import Foundation
import UIKit
let rect = NSRect(x: 50, y: 50, width: 100, height: 100)

And then I receive an error saying "Use of unresolved identifier 'NSRect"." What am I doing incorrectly?

Thank you for your help!

Upvotes: 1

Views: 2329

Answers (1)

Yatheesha
Yatheesha

Reputation: 10432

Use CGRect instead of NSRect . NSRect is for Cocoa, if project is for mac app use import Cocoa.

import Foundation
import UIKit
let rect = CGRect(x: 50, y: 50, width: 100, height: 100)

Upvotes: 3

Related Questions