iOS Swift/error 해결 방법2 sqlite3 select할때 한 줄만 주구장창 나온다면? func selectSiteData(clientName: String) -> [TrustedSiteData]{ //데이터 조회 let selectQuery = "select * from sitetable where clientname like '%\(clientName)%'" var statement: OpaquePointer? = nil var result: [TrustedSiteData] = [] if sqlite3_prepare_v2(self.db, selectQuery, -1, &statement, nil) == SQLITE_OK { while (sqlite3_step(statement) == SQLITE_ROW){ let result1 = Int(sqlite3_column_int(statemen.. 2022. 12. 22. Initializer for conditional binding must have Optional type, not 'String' 상단의 코드에서 if let docuPath = directory.path로 잡아주게 되면 제목과 같이 조건부 바인딩의 초기자(initializer)는 옵셔널형이어야하며, String일수 없다는 에러가 뜹니다. 있을지 없을지도 모르는데 어떻게 저렇게 쓰니? 하는 것이죠... let docuPath = directory.path if !docupath.isEmpty { let fileNames = try FileManager.default.contentsOfDirectory(atPath: docuPath) for fileName in fileNames { if fileName == named { let filePathName = "\(docuPath)/ \(fileName)" try FileManager... 2022. 12. 22. 이전 1 다음