NSString *string = @"oop:ack:bork:greeble:ponies";
NSArray *chunks = [string componentsSeparatedByString: @":"];


Posted by 꿈을펼쳐라
,

세팅 번들의 멀티밸류 값이 고정되어 있는 것이 아니라 사용자 필요에 의해 변경될 경우가 있다. 

나의 경우에는 길이나 넓이 단위를 사용자가 추가할 경우가 있는데, 이럴 경우 세팅 번들의 멀티 밸류항목에도 추가 시켜줘야하는 상황이 발생한다.  


hedar file  정의 : userDefaultSet.h

#import <Foundation/Foundation.h>


@interface UserDefaultSet : NSObject

{

    NSString *_strSettingBundlePath;

    NSMutableDictionary *_rootPList;

    

}


-(void) saveSettings;

-(void) loadSettings;


-(BOOL) setUserDefaultMultiValue:(NSString *)strID key:(id)keyArray value:(id)valueArray;

-(void) saveUserDefaultSet;


@end


 source file :UserDefaultSet.m

#import "UserDefaultSet.h"


@implementation UserDefaultSet


-(id) init

{

    if(self = [super init])

    {

        NSString* settingsBundle = [[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"] stringByAppendingPathComponent:@"Root.plist"];

        _strSettingBundlePath = [[NSString alloc] initWithFormat:@"%@",settingsBundle];

        

        NSDictionary *settingsPropertyList = [NSDictionary dictionaryWithContentsOfFile:_strSettingBundlePath];

        _rootPList = [[NSMutableDictionary alloc] initWithDictionary:settingsPropertyList];

        

    }    

    return self;       

}


-(void) dealloc

{

    [_strSettingBundlePath release];

    [_rootPList release];

    

    [super dealloc];

 }


-(void) saveSettings

{

    

}

-(void) loadSettings

{

    

}


- (BOOL) setUserDefaultMultiValue:(NSString *)strID key:(id)keyArray value:(id)valueArray 

{

    NSMutableArray* specifiers = [_rootPList objectForKey:@"PreferenceSpecifiers"];

//    NSMutableDictionary *multiValueSpecifier = [[NSMutableDictionary alloc] init];

    NSDictionary *multiValueSpecifier;    

    

    for (NSDictionary *specifier in specifiers)

    {

        if ([[specifier objectForKey:@"Key"] isEqualToString:strID] == YES &&

            [[specifier objectForKey:@"Type"] isEqualToString:@"PSMultiValueSpecifier"] == YES)

        {

            multiValueSpecifier = specifier;    

            break;

        }

    }

    

    if (multiValueSpecifier == nil)

        return FALSE;

    

    [multiValueSpecifier setValue:valueArray forKey:@"Values"];

    [multiValueSpecifier setValue:keyArray forKey:@"Titles"];

    

    NSLog(@"=== rootPlist:%@", _rootPList);    

    

    return [_rootPList writeToFile:_strSettingBundlePath atomically:YES];    

}


'아이폰개발 > Tip &amp; Tech' 카테고리의 다른 글

[XCode] bounds와 fame의 차이  (0) 2012.02.10
mainWindow.xib 사용하지 않고 어플 개발하기  (0) 2011.12.07
window와 _window의 차이  (0) 2011.10.13
FlipView구현 및 Toolbar 넣기  (0) 2011.10.13
NS Collection  (0) 2011.08.21
Posted by 꿈을펼쳐라
,

bounds :  영역의 사이즈를 설정
frame : 사이즈와 시작점을 동시에 정해줌.


[적용예]

view1.bounds = CGRectMake(0,0,100,100);
view1.center = CGPointMake(75,75);

혹은

view1.frame = CGRectMake(50,50,100,100);



from 맥부기 "coolmarklee님'
Posted by 꿈을펼쳐라
,

간단한 기능을 테스트하기 위해서, 아니면 너무 복잡한 뷰를 좀더 자유도 높게 개발하기 위해서 IB(Interface Builder)를 사용하지 않고, 앱을 개발하는 방식이 있다.

최근 개발하고자하는 앱의 기능 구현을 테스트하기 위한 테스트 베드용 앱을 만들어 적용하는 단계에서 단순화를
위해 IB 없이 개발하는 방식을 적용해 보았다.

하지만, XCode를 사용해서 Project를 생성하면 기본적으로 MainWindow.xib라는 파일이 생기게 되는데, 이것까지도 삭제하고 앱을 만들어 보았다.  나름 까다롭지만, 좋은 공부가 되었다.


1. File > New Project > "Window based Appliaction" 선택 (제일 단순한 어플) 

2. main.m 파일에서 다음 내용 수정 
// int retVal = UIApplicationMain(argc, argv, nil, nil);    => original Code 를 아래 내용으로 대체
int retVal = UIApplicationMain(argc, argv, nil, @"MapAppDelegate");  
 
3. MapAppDelegate.m 파일에서 뷰컨트롤 초기화

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
         // 어플 런칭 완료 함수가 아래 것으로 대체
}

- (void) applicationDidFinishLaunching:(UIApplication*)application
{

CGRect screenBounds = [[UIScreen mainScreen] bounds];

m_window = [[UIWindow alloc] initWithFrame: screenBounds];
m_view = [[UIView alloc] initWithFrame: screenBounds];
}


4. view loading 시 호출함수  
 
// Xib가 있는 뷰 호출
-(void) viewDidLoad
{         
}

// Xib가 없는 뷰  호출
-(void) loadView
{         
}

'아이폰개발 > Tip &amp; Tech' 카테고리의 다른 글

[setting.bundle] multivalue 동적으로 추가하기  (0) 2012.05.04
[XCode] bounds와 fame의 차이  (0) 2012.02.10
window와 _window의 차이  (0) 2011.10.13
FlipView구현 및 Toolbar 넣기  (0) 2011.10.13
NS Collection  (0) 2011.08.21
Posted by 꿈을펼쳐라
,

기존 XCode 3.x대에서 작성되었던 소스파일을 갖고 와서 XCode 4.x에서 작업을 하는데, 컴파일까지는 잘되는데 의도된 데로 실행되지 않는 경우가 발생하여 2시간 여를 끙끙 앓다가 해결된 문제다 .

[선언]
@interface
 TestAppDelegate : NSObject <UIApplicationDelegate> {

    IBOutlet UIWindow*          window;    => 기존 XCode 3.x에서 선언한 변수

}

@property (nonatomicretainIBOutlet UIWindow *window;

@end



[구현]

@synthesize window=_window;       => XCode 4.x Template

@synthesize viewController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    // 윈도우 표시

    [_window addSubview:viewController.view];

    [self.window makeKeyAndVisible];


위에서 구현부에서 사용했던, _window나  self.window는 결국 내가 선언한 window변수가 아닌 iOS내부변수인 _window를 사용하고 있는 듯하다. 

결국 이 문제는 선언부에서 "IBOutlet UIWindow*          _window;"로 수정하면서 말끔히 해결 됐다. 

 

@synthesize window=_window;  으로 선언했다면  

self.window를 통해  _window 변수에 접근하겠다는 선언이다.  
Posted by 꿈을펼쳐라
,
- Flip View 구현 :
     http://cafe.naver.com/mcbugi.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=74279&  
    View controller 기반


- TableView에 Toolbar 넣기 

UIToolbar *toolBar = [[UIToolbar allocinitWithFrame:CGRectMake(0.0431.032049.0)]; 

toolBar.barStyle = UIBarStyleBlackTranslucent

[self.view insertSubview:toolBar atIndex : 1]; 

UIBarButtonItem *bt1 = [[UIBarButtonItem allocinitWithTitle:@"bt1" style:UIBarButtonItemStyleBordered target:selfaction:@selector(cmd:)];

toolBar.items = [NSArray arrayWithObjects:bt1, nil];




 
Posted by 꿈을펼쳐라
,
NSArray류의 Collection은 NSObject에서 상속받은 객체만 넣을 수 있다.


1. NSObject에서 상속 받은 객체만을 담을 수 있음 
  - 일반 자료형이나 구조체, 클래스는 넣을 수 없음
  - int 형을 넣기위한 방법

NSNumber *a = [NSNumber alloc] initWithInt:100];

NSArray *array = [NSArray arrayWithObjects: a, nil];

[a release];


2. 메모리 해제
  [NSArray arrayWithObject:...] 컨비넌스 컨스트럭터

[NSArray alloc] init...]으로 만든 객체는 개발자가 직접 release 주어야 하는 것과는 달리, 컨비년스 컨스트럭터로 생성한 객체는 Auto Release Pool이라는 곳에 등록되기 때문에 나중에 자동으로 해제가 됩니다.

임시 객체 용도로 간단하게 사용하기 위해 사용한다고 생각하면 됩니다. (Auto release Pool 던져지니 수동으로 release하면 안됩니다!)


'아이폰개발 > Tip &amp; Tech' 카테고리의 다른 글

window와 _window의 차이  (0) 2011.10.13
FlipView구현 및 Toolbar 넣기  (0) 2011.10.13
[아이폰 시뮬레이터] 물리적 파일 위치  (0) 2011.08.15
Mac 단축키 정리  (0) 2011.07.30
[Object-C] 화면 캡쳐 방법  (0) 2010.07.30
Posted by 꿈을펼쳐라
,

아이폰 앱 개발을 위해서 사용하고 있는 시뮬레이터 상에서 파일데이터를 읽거나 쓰는 경우가 종종 발생한다. 
그런 과정에서 가끔 디버깅을 위해서 해당 파일을 직접 접근해야 하는 경우가 발생하는 데, 이와 같이 시뮬레이터
상의 위치와 실제  Mac의 파일 경로하고는 어떤 상관 관계가 있을까? 

예상하시는 바와 같이, Mac 의 특정 위치에 시뮬레이터 정보를 기록하게 되는데, 첨부 이미지를 통해서 위치를 확인할 수 있다. 


[User Home]/라이브러리/Application Support/iPhone Simulator/4.3/Applications/App별 암호화된 이름/  ...




 

'아이폰개발 > Tip &amp; Tech' 카테고리의 다른 글

window와 _window의 차이  (0) 2011.10.13
FlipView구현 및 Toolbar 넣기  (0) 2011.10.13
NS Collection  (0) 2011.08.21
Mac 단축키 정리  (0) 2011.07.30
[Object-C] 화면 캡쳐 방법  (0) 2010.07.30
Posted by 꿈을펼쳐라
,

XCode 단축키

1. 헤더파일, 소스파일 전환 : Control + Command + 방향키 up
2. 불러온 이미지 원본이미지 크기로 만들기 : Command + '='

Command + 방향키 : 맨 끝
Option + 방향키 : 한단락씩
Shift + 방향키 : 선택

앞에것 지우기 : Control + D
Undo : Command + Z
Redo : Command + Shift + Z 

'아이폰개발 > Tip &amp; Tech' 카테고리의 다른 글

window와 _window의 차이  (0) 2011.10.13
FlipView구현 및 Toolbar 넣기  (0) 2011.10.13
NS Collection  (0) 2011.08.21
[아이폰 시뮬레이터] 물리적 파일 위치  (0) 2011.08.15
[Object-C] 화면 캡쳐 방법  (0) 2010.07.30
Posted by 꿈을펼쳐라
,

CGImageRef UIGetScreenImage(); 

출처 : http://www.tuaw.com/2009/12/15/apple-relents-and-is-now-allowing-uigetscreenimage-for-app-st/ 

흠흠...  뭐 간단하네~ 


추가방법 :

UIGraphicsBeginImageContext(mapView.bounds.size);

[[[mapView.layer sublayers] objectAtIndex:0] renderInContext:UIGraphicsGetCurrentContext()];

UIImage* mapImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext(); 

출처:맥부기 dasomer님

'아이폰개발 > Tip &amp; Tech' 카테고리의 다른 글

window와 _window의 차이  (0) 2011.10.13
FlipView구현 및 Toolbar 넣기  (0) 2011.10.13
NS Collection  (0) 2011.08.21
[아이폰 시뮬레이터] 물리적 파일 위치  (0) 2011.08.15
Mac 단축키 정리  (0) 2011.07.30
Posted by 꿈을펼쳐라
,