Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Swift Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Swift Programming
This is the forum to discuss the Wrox book Beginning Swift Programming by Wei-Meng Lee; ISBN: 978-1-119-00931-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Swift Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 4th, 2015, 01:56 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2015
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default CH 3 Interoperabilty with NSString

I could not get this code to work. Xcode reports containsString unknown selector.

Code:
var str1 = "This is a Swift string"
println((str1 as NSString).containsString("Swift")) ---true---
You need to be running OS 10.10 before this will work. I'm on 10.9.

Mitch
Reply With Quote
The Following User Says Thank You to Mitchb For This Useful Post:
  #2 (permalink)  
Old June 24th, 2015, 08:04 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2015
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default

In chap 3, another error codes for character type conversion to NSString.

var bouquet = "\u{1F490}" // Character

println((bouquet as NSString).length) //Err: Character can't be converted to NSString

println(bouquet)
println("\(bouquet)") // String
println(String(bouquet)) // Character to String
println(count("\(bouquet)")) //---1---
println(count(String(bouquet))) //---1---

From above, you have to convert a Chacater to be a String by String() typecast, then to NSString. It will get error by "as NSString" directly.

println((NSString(string:String(bouquet)))) // Convert a character to a NSString
println((NSString(string:String(bouquet))).length) // ---2---


Leon
Reply With Quote
The Following User Says Thank You to leonwang777 For This Useful Post:
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 4 and Ch 13/15 - controls and the DataPager AlanWheeler BOOK: Beginning ASP.NET 4.5 : in C# and VB 3 February 24th, 2014 04:56 PM
Sending NSString to another viewController nickpsaris BOOK: Professional iPhone and iPad Database Application Programming 1 January 19th, 2012 12:54 AM
Ch 9-but will learn more abt User Controls (ch 8) btcomp BOOK: Beginning ASP.NET 4 : in C# and VB 1 August 24th, 2010 12:40 PM
Search ch 13, ch 16 sporik BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 October 27th, 2009 05:44 PM
Ch. 4 & Ch. 12 athena BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 23rd, 2004 11:54 AM



All times are GMT -4. The time now is 02:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.