Attempted to scroll the collection view to an out-of-bounds item (0) when there are only 0 items in section 0.

 

늦은 업데이트를 진행하였고 시뮬레이터가 15.2가 되었다.

회사 프로젝트를 돌려보던중 시뮬레이터에서 위와 같은 에러가 나면서 종료가 되고있다.

 

내용만 봐선 "아이템이 0인데 스크롤을 0으로 하려고한다 그러지마 "  라며 친절히 문제되는 부분을 알려주지만

 

이전에는 됐는데?

 

참담한 심정으로 콜렉션뷰의 스크롤하는 부분

      self.collectionView.scrollToItem

부분을

if (.count != 0 ) 를 걸어주어 0 이후에 변경될때만 호출해주도록 변경하였다.

 

동작은 한다

 

뭔가 미묘한 기분

반응형

https://www.viget.com/articles/animated-ios-launch-screen/

 

Animate Your iOS Splash Screen | Viget

Learn how to animate iOS launch screens however you want!

www.viget.com

 

반응형

https://github.com/raywenderlich/swift-algorithm-club

반응형

https://github.com/morizotter/KeyboardObserver

 

GitHub - morizotter/KeyboardObserver: For less complicated keyboard event handling.

For less complicated keyboard event handling. Contribute to morizotter/KeyboardObserver development by creating an account on GitHub.

github.com

 

매번 Notification으로 받고 하는게 뭔가 안좋아보여서 참고할 오픈소스....

 

나중에 보자

반응형

https://xho95.github.io/swift/programming/language/grammar/2017/02/28/The-Swift-Programming-Language.html

 

Swift 5.5: Swift Programming Language (스위프트 프로그래밍 언어)

 

xho95.github.io

애플 공식 swift 5.5 문서를 번역하는 블로그.

반응형

'iOS > swift' 카테고리의 다른 글

메모. 스위프트 알고리즘  (0) 2022.01.12
KeyboardObserver~  (0) 2021.10.19
UIPickerView 의 텍스트 색상 변경하는 방법  (0) 2021.06.17
프로그래머스 - 프린터  (0) 2021.05.06
프로그래머스 - 기능개발  (0) 2021.05.05

https://khushwanttanwar.medium.com/xcode-12-compilation-errors-while-running-with-ios-14-simulators-5731c91326e9

 

Xcode 12 Compilation Errors (While running with iOS 14 Simulators)

Migrating to the latest Version 12.0.1 (12A7300) version, while compiling the running project, it gives errors with simulator selected…

khushwanttanwar.medium.com

 

 

m1 mac mini로 기존 프로젝트들이 돌아가는지 테스트중에 

해당 문제가 발생했다.

 

해결은 아래와같이 했다.

  • To do that for Main Project, navigate to Build Settings of your project and add Any iOS Simulator SDK with value arm64 inside Excluded Architecture. (Note: Project, not Target. Adding to Project will automatically add settings to all its Target)

 

감사 그자체

 

반응형

88. 콘솔에서 네 개의 정수( a, m, d, n )를 입력받고, a를 시작값 으로갖고 m을 곱하고 d 를 더한 값이 다음값으로 갖는 수열의 n번째 수를 출력하라.

( ex : a , a*m+d, (a*m+d)*m+d, ....)

입력: 1Line 에 공백을 두고 4개의 정수가 입력됨

입력 범위 : a,m,d : -50 ~ 50, n: 1 ~ 10​

입력 예시

1 -2 1 8

출력 예시

-85

JAVA

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int startNum = scan.nextInt();
		int mulNum = scan.nextInt();
		int addNum = scan.nextInt();
		int targetIndex = scan.nextInt();
		scan.close();
		
		int result = startNum;
		for (int i = 1; i < targetIndex; i++) {
			result *= mulNum;
			result += addNum;
		}
		
		System.out.println(result);
	}
}

Swift 4.2

import Foundation

if let line = readLine(){
    let valueArray = line.split(separator: " ")
    if valueArray.count == 4,
        let startNum = Int(valueArray.first!),
        let mulNum = Int(valueArray[1]),
        let addNum = Int(valueArray[2]),
        let targetIndex = Int(valueArray[3])
    {
        var result = startNum
        for _ in 1 ..< targetIndex {
            result *= mulNum
            result += addNum
        }
        print(result)
    }
}

이전 코드에서 덧셈부분만 추가됏습니다.

음... 수학문제도 프로그래밍으로 풀수있다! 라는걸 알려주려고 낸 문제였을까요?

https://codeup.kr/problem.php?id=1091

 

 

반응형

87. 콘솔에서 세개의 정수( a, r, n )를 입력받고, a를 시작값, r을 등비값으로 가지는 등비수열의 n번째 값을 출력하라.

입력: 1Line 에 공백을 두고 3개의 정수가 입력됨

입력 범위 : 0 ~ 7

입력 예시

2 3 7

출력 예시

1458

JAVA

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int startNum = scan.nextInt();
		int mulNum = scan.nextInt();
		int targetIndex = scan.nextInt();
		scan.close();
		
		int result = startNum;
		for (int i = 1; i < targetIndex; i++) {
			result *= mulNum;
		}
		
		System.out.println(result);
	}
}

Swift 4.2

import Foundation

if let line = readLine(){
    let valueArray = line.split(separator: " ")
    if valueArray.count == 3,
        let startNum = Int(valueArray.first!),
        let mulNum = Int(valueArray[1]),
        let targetIndex = Int(valueArray[2])
    {
        var result = startNum
        for _ in 1 ..< targetIndex {
            result *= mulNum
        }
        print(result)
    }
}

이전 문제에서 부호랑 변수명만 바꾸었습니다.

https://codeup.kr/problem.php?id=1090

반응형

+ Recent posts