The method is available in the project, but not in the playground.

I'm new to Swift - using Swift 3, Xcode 8.0 beta 6, Mac OS X 10.11.6. The following line works in my project (this is a simple test case to see if the "contains" method works):

if ("hello John".contains("John")){}

It works great in my project, but when I cut it out and paste it into the playground project, it gives an error:

"A value of type 'String' has no member 'contains'.

My question is, in addition to why this error occurs, are there different frameworks / functions / methods, etc., used in playground projects from ordinary projects? Thank you for your help. Squire

+4
source share
1 answer

- , :

like

import Foundation // responsible for strings for example

import UIKit // responsible for UI elements

... ..

enter image description here

+3

Source: https://habr.com/ru/post/1654908/


All Articles