반응형

Programming 61

delegate 함수 호출 시 반드시 체크

123if ([delegate respondsToSelector:@selector(didLocateUser)]) { [delegate didLocateUser];}Colored by Color Scriptercs http://stackoverflow.com/questions/9018764/not-implemented-delegate-method-leads-to-crash didLocateUser 라는 함수를 호출하는데, 받아줄 함수가 구현되어있지 않은 경우 알 수 없는 함수를 호출했다고 에러가 뜨며 앱이 멈춘다 delegate를 통해 깔끔한 코드를 작성할 수 있는데,이것을 포기하지 않으려고 검색하던 도중 함수 구현 여부를 확인하는 코드를 발견함

Programming 2016.12.13

[Unity] UFO 한칸씩 움직이기

단순한 방식으로 물체를 움직일 수 있는 방법transform.Translate(new Vector3(x,y,z));물체에 대한 다른 설정을 해주지 않아도 스크립트가 해당 물체에 걸려있기 때문에 자동으로 설정되는 것 같다. using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } public void moveObject(){ transform.Translate (new Vector2(1,0)); } }

Programming 2016.08.27

[Android] 클래스 생성 시, 변수 개수에 따라 센스있게 처리해주기

// parameter 2개만 있을 떄 처리해줌 public Note(@Nullable String title, @Nullable String description){ this(title, description, null); } public Note(@Nullable String title, @Nullable String description, @Nullable String imageUrl){ mId = UUID.randomUUID().toString(); mTitle = title; mDescription = description; mImageUrl = imageUrl; } 변수가 2개만 있을 때 위의 메소드가 받아주고, 맨마지막 변수에 null 값을 넣어서 변수 3개까리 메소드가 처리해준다감동적ㅋㅋ

Programming 2016.08.23
반응형