2014-06-06 4 views
2

저는 프로젝트에서 신속한 놀이터를 만들었습니다. 나는이스위프트 놀이터 UIImage 소개

var img2 = UIImage(named : "Demo") 

를 추가 할 때 그러나 그것은 나에게 다음과 같은 콘솔 출력을 제공합니다

Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x20). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1: tid = 0xac9f4, 0x00000001001a8797 libswift_stdlib_core.dylib (anonymous namespace)::getImplementationForType(swift::Metadata const*, swift::OpaqueValue const*) + 247, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20) * frame #0: 0x00000001001a8797 libswift_stdlib_core.dylib (anonymous namespace)::getImplementationForType(swift::Metadata const*, swift::OpaqueValue const*) + 247 frame #1: 0x00000001001a8416 libswift_stdlib_core.dylib swift_reflectAny + 198 frame #2: 0x000000010033d603 PlaygroundLogger PlaygroundLogger.PlaygroundObjectWriter.encode_object (PlaygroundLogger.PlaygroundObjectWriter)(A, Swift.String) ->() + 707 frame #3: 0x000000010031ba5f PlaygroundLogger`playground_log + 319 frame #4: 0x000000010bafa174

나는 Images.xcassets에 이미지를 추가했다. .swift 파일에서는이 코드를 실행할 수 있지만 .playground에서는 실행할 수 없습니다.

놀이터 설정에서 자원 경로를 변경하려고합니다.

"Playground execution terminated because the playground process exited unexpected"

+0

왜 이것을 다운 그레이드 했습니까? 나에게 좋은 질문 같아. – phatmann

답변

1

당신의 놀이터 설정을 재설정 시도하고 이미지를 저장 한 전체 경로를 입력 : 실행할 수 있습니다 만 '없음'옵션은 다른 사람들이 나에게 오류 메시지를 제공합니다.

var img2 = UIImage(named: "path/to/the/image") 

크레딧 : 아래에서 Swift playgrounds with UIImage

+0

지금은 괜찮다고 생각합니다. 하지만 놀이터 환경을 재설정하고 Xcode 6을 재부팅해야합니다. 코드가 지금 실행될 수 있습니다. 당신의 도움을위한 Thx – user3714585

+1

모든 것이 작동한다면,이 대답을 받아 들여이 문제를 끝낼 수 있습니다 :) – mstottrop

3

에 "놀이터 설정"가서 "자원 경로"선택 "관리자가 파일"- 그것에 탭, 폴더 아이콘이 있음> "절대 경로"를, 아래에 . "파인더"가 열리면 이제 자원/이미지 폴더를 선택하고 "선택"을 탭할 수 있습니다. 다음과 같이 확장명을 가진 이미지 이름을 사용할 수 있습니다.

let image = UIImage(named:"photo1")