type casting2 15. Objective-C typedef, type casting typedefObjective-C의 typedef는 Swift의 typealias와 동일한 기능을 수행한다.둘 다 기존 타입에 새로운 이름을 부여하여 가독성을 높이고 코드의 간결성을 유지하는 데 사용된다. //Swift typealias MyUnsignedInt = UInt let value: MyUnsignedInt = 10 Objective-C typedef// 이제 BYTE는 unsigned char 대신 쓰이게 된다.// 구별을 위해 주로 대문자로 작성한다.typedef unsigned char BYTE;BYTE b1; 구조체의 typedef 사용typedef struct Musics { NSString *title; NSString *artist; int playTimeSec;}.. 2024. 5. 17. 6. 스코프(Scope), 타입캐스팅(Type Casting)_형변환 변수는 기본적으로 선언 위치에 따라 전역 변수, 지역 변수, 클래스 변수(클래스 변수, 인스턴스 변수) 등으로 분류된다. 지금까지 학습하면서 함수 내부에서 사용한 변수들은 로컬 변수(Local Variable)로 코드 블럭을 벗어나면 사용이 불가능했다. public class Scope1 { public static void main(String[] args) { int mainVariable = 10; if (true) { int ifVariable = 20; // x는 조건문 코드블럭 내부에서만 사용 가능 System.out.println("ifVariable = " + ifVariable); // m은 main 메서드 코드블럭 내부에서만 사용 가능 System.out.println("mainVari.. 2024. 1. 21. 이전 1 다음