<네비게이션 바 아래에 동적으로 늘어나는 옵션 메뉴 넣기> from xguru in twitter

<OAuth>
 
<페이스북, 트워터, 구글 리더 등에서 글, 그림, URL, 파일등을 공유하는 라이브러리>
 
<네이트 Open API 라이브러리>
 
<페이스북 연동 라이브러리>
 
<TCP, UDP Socket Class 라이브러리>
 
<기본 클래스를 확장한 라이브러리>
 
<iPhotoDiary, 육아일기 어플리케이션>
 
<DropBox를 통한 파일 공유 API 사용 예제 소스>
 
<JSON Library> ----------------------------------------------------------------------------
JSONKit :
 
SBJSON
 
TouchJSON
 
<XML Parser> ------------------------------------------------------------------------------

GDataXML :

http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Source/XMLSupport/ (소스)

http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml (해설)

 

TBXML : (read only, XPath 미지원)

http://www.tbxml.co.uk/TBXML/TBXML_Free.html

 

TouchXML : (read only, XPath 지원)

https://github.com/TouchCode/TouchXML

 
KissXML : (read/write)
 
여러가지 XML Parser에 대한 성능 비교 및 사용 용도 설명
 
<zip/unzip lib> ------------------------------------------------------------------------------
 
 
<AVPlayer: LGPL로 FFmpeg, SoundTouch를 사용했다고 나오네요> 
 
<무인코딩 동영상 플레이어 VLC iPhone, iPad>
 
<web server>
 
<bar code, QR code>
 
<push notification service 관련 provider>

 
<web 게시판과 연동>

http://cocoadev.tistory.com/#recentTrackback에서 공개한 내용임.
      *  이미지 편집 함수 모음( 스케일, 회전, crop 등)
  • 다양한 UI 구현
  • 테이블뷰셀 커스터마이징
  • HTTP GET/POST 요청
  • XML 파싱
  • 사진 앨범, 카메라, 지도 이미지 접근
  • 맵뷰 및 위치정보
  • 푸시 노티피케이션

<여러 UI 모음: photo viewer, etc>
http://github.com/facebook/three20 (초기에는 facebook 어플이었으나 현재는 여러 UI 모음으로 바뀜 )

<map>

<E-mail>
 
 
<달력>
http://ved-dimensions.blogspot.com/2009/04/iphone-development-creating-native_09.html

<sqlite>

<계산기>

<트위터 클라이언트>
http://github.com/blog/329-natsuliphone-iphone-twitter-client
http://code.google.com/p/tweetero/

<facebook>

<rss reader>
http://code.google.com/p/iphone-simple-rss-aggregator/

<ebook reader>
http://code.google.com/p/iphoneebooks/

<blog>
http://iphone.wordpress.org/

<백업, 동기화>
http://www.funambol.com/solutions/iphone.php
http://code.google.com/p/gris/ (구글 리더 동기화)

<time tracking>
http://github.com/freshbooks-addons/freshbooks-iphone-project

<게임>
http://code.google.com/p/cocos2d-iphone/
http://code.google.com/p/tris/ (테트리스)
http://code.google.com/p/mintgostop/ (고스톱)

 

<google toolbox>

http://code.google.com/p/google-toolbox-for-mac/


<택배>

 

<이미지 프로세싱>

http://code.google.com/p/simple-iphone-image-processing/


<증강현실>
http://www.iphonear.org/

<coverflow 대체 구현>
http://apparentlogic.com/openflow/
http://www.chaosinmotion.com/flowcover.m (매가박스 어플에서 참고함)

<정규표현식 라이브러리>
http://blog.mro.name/2009/09/cocoa-wrapped-regexh/
http://regexkit.sourceforge.net/RegexKitLite/

<라이브러리 : JSON, DOM XML, Google Data APIs, Twitter, Flick, Game Engines, Unit Testr>
http://www.codingventures.com/2008/12/useful-open-source-libraries-for-iphone-development/

<기타>
http://open.iphonedev.com/
http://joehewitt.com/post/the-three20-project/

'Object-C' 카테고리의 다른 글

아이폰에서 3G 인지 와이파이인지 알아보는 방법  (0) 2010.12.22
단축키  (0) 2010.12.17
태그로 서브뷰 찾기  (0) 2010.12.15
NSLog  (0) 2010.12.15
adHoc  (0) 2010.12.13
애플 개발 사이트에서 Reachability로 검색을 한 후 샘플코드를 다운 받는다.

해당 파일에서 Reachability.h / Reachability.m 파일만 현재 프로젝트에 추가시킨 후

SystemConfiguration.framework 프레임을 추가시킨다. 
원하는 뷰에서 Reachability.h를 import 한 후 

int result = [[Reachability reachabilityForInternetConnection] currentReachabilityStatus]; NSLog(@"--%i",result ); 
결과가 0이면 접속불능 
1이면 와이파이 
2이면 3G 상태이다.

'Object-C' 카테고리의 다른 글

iphone open source  (0) 2011.06.19
단축키  (0) 2010.12.17
태그로 서브뷰 찾기  (0) 2010.12.15
NSLog  (0) 2010.12.15
adHoc  (0) 2010.12.13

control + command  + T :      Edit All in Scope
control + D :                         커서의 오른쪽 문자를 지움
control + K :                         라인의 나머지 부분을 지움 (Kill)
command + shift + D :           Open Quick 
command + R :                    북마크 추가
command + shift + F :           파일검색
option + click (창분할) :         세로로 창분할
command + control + S :       스냅샷을 만든다

-디버깅
command + option + P : 다시실행
command + option + O : 한줄실행후 멈춤
command + shift + T : 함수를 호출한 다음라인에서 개발자에게 제어권을 넘김
command + shift + Y : 디버거 실행


'Object-C' 카테고리의 다른 글

iphone open source  (0) 2011.06.19
아이폰에서 3G 인지 와이파이인지 알아보는 방법  (0) 2010.12.22
태그로 서브뷰 찾기  (0) 2010.12.15
NSLog  (0) 2010.12.15
adHoc  (0) 2010.12.13
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibname:@"PhotoTableCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}

NSDIctionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row];

UILabel *label;
lable = (UILabel *)[cell viewWithTag:2];
lable.text = [photoData valueForKey:@"Country"];

label = (UILabel *)[cell viewWithTag:3];
lable.text = [photoData valueForKey:@"Region"];

UIImageView *imageView= (UIImageView *)[cell viewWithTag:1];
imageView.image = [photoData valueForKey:@"Thumbnail"];

return cell;
}

'Object-C' 카테고리의 다른 글

아이폰에서 3G 인지 와이파이인지 알아보는 방법  (0) 2010.12.22
단축키  (0) 2010.12.17
NSLog  (0) 2010.12.15
adHoc  (0) 2010.12.13
category  (0) 2010.12.03

NSLog(@"%s", _FUNCTION_);

_FUNCTION_ : 메서드

_LINE_  : 라인수

_FILE_ : 파일명

'Object-C' 카테고리의 다른 글

단축키  (0) 2010.12.17
태그로 서브뷰 찾기  (0) 2010.12.15
adHoc  (0) 2010.12.13
category  (0) 2010.12.03
init  (0) 2010.12.03

'Object-C' 카테고리의 다른 글

태그로 서브뷰 찾기  (0) 2010.12.15
NSLog  (0) 2010.12.15
category  (0) 2010.12.03
init  (0) 2010.12.03
textbox 글자수에 따른 height 가져오기  (0) 2010.11.26
.h ---------------
#import <Cocoa/Cocoa.h> @interface NSString (Utilities) - (BOOL) isURL; @end

.m -----------------
#import "NSString-Utilities.h" @implementation NSString (Utilities) - (BOOL) isURL { if ( [self hasPrefix:@"http://"] ) return YES; else return NO; } @end


usese -----------------

NSString* string1 = @"http://pixar.com/"; NSString* string2 = @"Pixar"; if ( [string1 isURL] ) NSLog (@"string1 is a URL"); if ( [string2 isURL] ) NSLog (@"string2 is a URL");

'Object-C' 카테고리의 다른 글

NSLog  (0) 2010.12.15
adHoc  (0) 2010.12.13
init  (0) 2010.12.03
textbox 글자수에 따른 height 가져오기  (0) 2010.11.26
HIG  (0) 2010.11.07
--------------- tire.m-------------------

- (id) init { if ( self = [slef initWithPressure:34 treadDepth:30] ) { } return (self); }

- (id) initWithPressure : (float)p
{
if(self = [self initWithPressure:p treadDepth:20.0])
{
}

return (self);
}

-(id) initWithTreadDepth : (float)td
{
if(self = [self initWithPressure:34.0 threadDepth:td])
{
}
return (self);
}

-(id) initWithPressure:(float)p threadDepth:(float)td
{
if(self = [super init])
{
pressure = p;
treadDepth = td;
}
return (self);
}


------------------------- subClassing --------------------------------

-(id)initWithPressure:(float)p threadDepth:(float)td
{
if(self = [super initWithPressure:p treadDepth:td])
{
rainHandling = 23.7;
snowHandling = 43.5;
}

return (self);
}

'Object-C' 카테고리의 다른 글

adHoc  (0) 2010.12.13
category  (0) 2010.12.03
textbox 글자수에 따른 height 가져오기  (0) 2010.11.26
HIG  (0) 2010.11.07
Memory Management  (0) 2010.11.02

int nMaxWidth = 220

int nMaxHeight = 400;   

UIFont *chatFont = [UIFont systemFontOfSize:14];

_tagDetail.text = @"";

CGSize chatTextSize = [_tagDetail.text sizeWithFont:  chatFont

  constrainedToSize: CGSizeMake(nMaxWidth, nMaxHeight)

  lineBreakMode: UILineBreakModeWordWrap];

int height = chatTextSize.height;

'Object-C' 카테고리의 다른 글

category  (0) 2010.12.03
init  (0) 2010.12.03
HIG  (0) 2010.11.07
Memory Management  (0) 2010.11.02
StanFord Lecture PDF  (0) 2010.10.29
http://blog.naver.com/wwind18/20110361242

'Object-C' 카테고리의 다른 글

init  (0) 2010.12.03
textbox 글자수에 따른 height 가져오기  (0) 2010.11.26
Memory Management  (0) 2010.11.02
StanFord Lecture PDF  (0) 2010.10.29
테이블뷰 정렬  (0) 2010.10.23
Reference Count

  Objective-C에서의 메모리 관리는 reference count(retain count)라는 개념에 의해서 이루어진다. Reference count는 해당 object에 대한 reference가 몇개 있는지 나타내는 것으로서, new, alloc, copy 등에 의하여 메모리 공간이 할당되고 새로운 object가 생성되면 reference count는 1이 된다. 그 object에 대한 참조가 늘어날때 마다 count도 하나씩 증가하고 참조가 없어질 때마다 count는 하나씩 감소하며 count가 0이 되는 순간, 즉 아무것도 그 object를 참조하지 않게 되면 자동적으로 dealloc 메소드가 호출되어 그 object는 사라지고 그것이 차지하고 있던 메모리 공간이 반환된다.

  NSObject는 다음과 같은 메소드를 갖고 있다.

    - (id) retain;  /* retainCount++, return self. 

                     * Used when you want to prevent it from being deallocated 

                     * without your express permission. */

    - (void) release;  /* retainCount-- */

    - (unsigned) retainCount;  /* return retainCount */



Autorelease

  효율적인 메모리 관리와 메모리 누수 방지를 위하여 메모리 공간의 할당 및 반환을 제때 잘 해주어야한다. 그러나 프로그래머로서는 누가 언제 어떤 메모리 공간을 할당, 반환해야하는지 아는 것이 쉽지 않다. Cocoa는 메모리 관리를 보다 간단히 해주기 위한 수단으로서 autorelease와 autorelease pool을 제공한다.

    - (id) autorelease;


  autorelease 선언된 object는 autorelease pool에 담기게 되고, 후에 autorelease pool이 release 또는 drain되면 pool에 담긴 모든 object에게 release 메세지를 날리게 된다. 다음의 메소드를 보자. 

    - (NSString*) description 

    {

        NSString* str = [[NSString allocinitWithFormat@"I am %d years old"4];

        return str;

    }


  위의 description 메소드는 NSString 객체를 alloc으로 생성하고 그 값을 초기화한 뒤 리턴하고 있다. 리턴된 str 객체는 프로그램의 다른 부분에서 사용될 것이다. 그렇다면 이 str을 사용한 뒤 release는 언제 어디에서 해주어야 하는가. 이러한 문제는 str 객체에 대하여 autorelease 선언을 해줌으로써 해결할 수 있다. 즉 위 코드의 마지막 줄을

 

    return [str autorelease];

  
로 바꿈으로써, 나중에 str이 담겨있는 autorelease pool을 release할 때 str이 release될 수 있도록 할 수 있다.



The Rules of Cocoa Memory Management

  Object는 몇 line의 코드에 걸쳐 잠시 일시적으로 사용되는 transient object와 메소드 호출 등으로 일정 시간동안 프로그램의 여러 부분에서 사용되는 hang on object로 구분할 수 있다. 이 두 가지 object의 메모리는 다음의 규칙에 의해 관리하는 것이 Cocoa의 convention이다.
    

- alloc/new/copy로 생성된 transient object
  사용 후 바로 release해준다.
    

    NSMutableArray* array = [[NSMutableArray allocinit];


    /* use the array */


    [array release];


- 그 외의 방법으로 생성된 transient object
  retain count는 1, 이미 autorelease 선언된 것으로 가정한다. 사용 후 아무것도 안해주어도 된다.

    NSMutableArray* array = [NSMutableArray arrayWithCapacity17];


    /* use the array */



- alloc/new/copy로 생성된 hang on object
  dealloc 메소드 안에서 release해준다.

    - (void) doStuff

    {

        // array is an instance variable

        array = [NSMutableArray new];

    }


    - (void) dealloc

    {

        [array release];

        [super release];

    }



- 그 외의 방법으로 생성된 hang on object
  retain count는 1, 이미 autorelease 선언된 것으로 가정한다. 생성 후 retain해주고, 사용 후 dealloc에서 release해준다.

    - (void) doStuff

    {

        // array is an instance variable

        array = [NSMutableArray arrayWithCapacity17];

        [array retain];

    }


    - (void) dealloc

    {

        [array release];

        [super release];

    }


'Object-C' 카테고리의 다른 글

textbox 글자수에 따른 height 가져오기  (0) 2010.11.26
HIG  (0) 2010.11.07
StanFord Lecture PDF  (0) 2010.10.29
테이블뷰 정렬  (0) 2010.10.23
키보드 사이즈 이벤트  (0) 2010.10.23

'Object-C' 카테고리의 다른 글

HIG  (0) 2010.11.07
Memory Management  (0) 2010.11.02
테이블뷰 정렬  (0) 2010.10.23
키보드 사이즈 이벤트  (0) 2010.10.23
트위터 posting  (0) 2010.10.22
NSSortDescriptor *nameSorter = [[NSSortDescriptor alloc] initWithKey:NAME_KEY ascending:YES selector:@selector(caseInsensitiveCompare:)];

[drinkArray sortUsingDescriptors:[NSArray arrayWithObject:nameSorter]];
[nameSorter release];

// caseInsensitiveCompare 별도로 지정하지 않으면 대소문자를 구별해서 정렬한다.

'Object-C' 카테고리의 다른 글

Memory Management  (0) 2010.11.02
StanFord Lecture PDF  (0) 2010.10.29
키보드 사이즈 이벤트  (0) 2010.10.23
트위터 posting  (0) 2010.10.22
valueForKey vs objectForKey  (0) 2010.10.22
-(void) keyboardDidShow:(NSNotification *)notifi
{
if(keyboardVisible)
{
NSLog(@"Keyboard is already visible. Ignoring notification");
return;
}

NSLog(@"Resizing smaller for keyboard");

NSDictionary *info = [notifi userInfo];

NSValue *aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;

CGRect viewFrame = self.view.frames;
viewFrame.size.height -= keyboardSize.height;

scrollView.frame = viewFrame;
keyboardVisible = YES;
}

-(void)keyboardDidHide:(NSNotification *)notifi
{
if(!keyboardVisible)
{
NSLog(@"Keyboard already hidden..");
return;
}

NSLog(@"Resizing bigger with no keyboard");

NSDictionary *info = [notifi userInfo];

NSValue *aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;

CGRect viewFrame = self.view.frames;
viewFrame.size.height += keyboardSize.height;

scrollView.frame = viewFrame;
keyboardVisible = NO;
}

'Object-C' 카테고리의 다른 글

StanFord Lecture PDF  (0) 2010.10.29
테이블뷰 정렬  (0) 2010.10.23
트위터 posting  (0) 2010.10.22
valueForKey vs objectForKey  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:
@"http://YOUR_TWITTER_USERNAME:YOUR_PASSWORD@twitter.com/status/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"status=%@", 
NSURLResponse *response;
NSError *error;
NSData *result = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:&response error:&error];
NSLog(@"%@", [[[NSString alloc] initWithData:result
encoding:NSASCIIStringEncoding] autorelease]);



'Object-C' 카테고리의 다른 글

테이블뷰 정렬  (0) 2010.10.23
키보드 사이즈 이벤트  (0) 2010.10.23
valueForKey vs objectForKey  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
valueForKey 는 코코아에서 키-밸류-코딩 패턴을 위해 사용합니다.

NSDictionary 의 valueForKey를 호출하면 내부적으로 다시 ObjectForKey 를 호출합니다.

 하지만 valueForKey 는 인자로 받는값을 확인하고 키의 종류에 따라서 다르게 동작합니다. 

코코아 바인딩을 하는 경우가 아니라면 이것은 원하는 것이 아닐수도 있습니다. 딕셔너리를 접근하는 올바른 메서드는 ObjectForKey 입니다.

'Object-C' 카테고리의 다른 글

키보드 사이즈 이벤트  (0) 2010.10.23
트위터 posting  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
MoviePlayer  (0) 2010.10.09
-(IBAction) textFieldDoneEditing:(id)sender
{
[sender resignFirstResponder];
}

//sender = textbox

'Object-C' 카테고리의 다른 글

트위터 posting  (0) 2010.10.22
valueForKey vs objectForKey  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
MoviePlayer  (0) 2010.10.09
MapView  (0) 2010.10.09
[[NSNotificationCenter defaultCenter] 
addObserver:self 
selector(launchFinished:) 
name:UIApplicationDidFinishLaunchingotification 
object:nil];

addObserver:통보를 받을 객체
name : nill = 모든이벤트에 대해서 통보를 받는다.
object : nil = 모든객체에서 이벤트발생시 통보
           특정object = 특정object 에서 이벤트 발생시 통보



[[NSNotificationCenter defaultCenter]
postNotificationName:@"myEventOccured"
object:objectX
userInfo:[NSDictionary dictionaryWithObject:@"value1" forKey:@"data1"]
];

object : 통보(이벤트)를 발생시키는 객체
userInfo : 통보를 보내는 객체가 추가정보를 전달할때 이용됨

'Object-C' 카테고리의 다른 글

valueForKey vs objectForKey  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
MoviePlayer  (0) 2010.10.09
MapView  (0) 2010.10.09
XML  (0) 2010.10.09


- (IBAction)btnFilePress:(id)sender {

NSString *path = [[NSBundle mainBundle] pathForResource:@"Moviecountdownwithsound" ofType:@"mp4"];

if (path) {

MovieURL = [NSURL fileURLWithPath:path];

}

//MPMoviePlayerController *thePlayer = [[MPMoviePlayerController alloc] initWithContentURL:MovieURL]; //ver 3.x

MPMoviePlayerViewController *thePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:MovieURL];

//thePlayer.scalingMode = MPMovieScalingModeAspectFit; //ver 3.x

thePlayer.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

thePlayer.moviePlayer.shouldAutoplay = YES;

[thePlayer shouldAutorotateToInterfaceOrientation:YES];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:thePlayer];

//[thePlayer play]; //ver 3.x

[self.navigationController presentModalViewController:thePlayer animated:NO];

}


- (void)myMovieFinishedCallback:(NSNotification *)aNotification {

MPMoviePlayerController *thePlayer = [aNotification object];

[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:thePlayer];

[thePlayer release];

}


- (IBAction)btnStreamPress:(id)sender {

NSString *path = @"http://movies.apple.com/media/us/iphone/2010/tours/apple-iphone4-design_video-us-20100607_r848-9cie.mov";


if (path) {

MovieURL = [NSURL URLWithString:path];

}

//MPMoviePlayerController *thePlayer = [[MPMoviePlayerController alloc] initWithContentURL:MovieURL]; //ver 3.x

MPMoviePlayerViewController *thePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:MovieURL];

//thePlayer.scalingMode = MPMovieScalingModeAspectFit;  //ver 3.x

thePlayer.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

thePlayer.moviePlayer.shouldAutoplay = YES;

[thePlayer shouldAutorotateToInterfaceOrientation:YES];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:thePlayer];

//[thePlayer play];  //ver 3.x

[self.navigationController presentModalViewController:thePlayer animated:NO];

}

'Object-C' 카테고리의 다른 글

키보드 사라지게 하기  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
MapView  (0) 2010.10.09
XML  (0) 2010.10.09
SQLITE  (0) 2010.10.08

UIViewController <MKMapViewDelegate, MKReverseGeocoderDelegate> {

...

}


- (void)viewDidLoad {

MKCoordinateRegion seoulRegion;

CLLocationCoordinate2D center;

center.latitude = 37.47783;

center.longitude = 127.044060;

MKCoordinateSpan span;

span.latitudeDelta = 0.005;

span.longitudeDelta = 0.005;

seoulRegion.center = center;

seoulRegion.span = span;

mapView.region = seoulRegion;

NSMutableArray *annotations = [[NSMutableArray alloc] init];

CLLocationCoordinate2D coord2d = {37.47783,127.044060};

MyAnnotation *anno = [[MyAnnotation alloc] initWithCoords:coord2d name:@"name1"];

anno.title = @"title1";

anno.subtitle = @"subtitle1";

[annotations addObject:anno];

[anno release];

CLLocationCoordinate2D coord2d1 = {37.480783,127.046060};

MyAnnotation *anno1 = [[MyAnnotation alloc] initWithCoords:coord2d1 name:@"name2"];

anno1.title = @"title2";

anno1.subtitle = @"subtitle2";

[annotations addObject:anno1];

[anno1 release];

[mapView addAnnotations:annotations];

[annotations release];

[super viewDidLoad];

}


-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>) annotation

{

MKPinAnnotationView *annoView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];

annoView.animatesDrop = YES;

UIButton *addButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

annoView.rightCalloutAccessoryView = addButton;

[annoView setCanShowCallout:YES];

[annoView setSelected:YES animated:YES];

[annoView release];

return annoView;

}

'Object-C' 카테고리의 다른 글

NSNotificationCenter  (0) 2010.10.10
MoviePlayer  (0) 2010.10.09
XML  (0) 2010.10.09
SQLITE  (0) 2010.10.08
CoreData  (0) 2010.10.07

@synthesize xmlView, xmlData, xmlList, currentItem, xmlValue;


- (void)viewDidLoad {

self.xmlData = [[NSData alloc] init];

self.xmlList = [[NSMutableArray alloc] init];

self.xmlValue = [[NSMutableString alloc] init];

self.currentItem = [[NSMutableDictionary alloc] init];

NSString *path = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"xml"];

NSData *data = [[NSData alloc] initWithContentsOfFile:path];

self.xmlData = data;

NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.xmlData];

[parser setDelegate:self];

[parser parse];

[parser release];

[xmlView reloadData];

[super viewDidLoad];

}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict

{

if ([elementName isEqualToString:@"d:entry"]) {

elementType = etItem;

}

[self.xmlValue setString:@""];

}


- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string

{

if(elementType == etItem){

[xmlValue appendString:string];

}

}


- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName

{

if(elementType != etItem)

return;

if([elementName isEqualToString:@"d:entry"]){

[self.xmlList addObject:[NSDictionary dictionaryWithDictionary:self.currentItem]];

}

else if([elementName isEqualToString:@"d:index"]){

[self.currentItem setValue:[NSString stringWithString:self.xmlValue] forKey:elementName];

}

else if([elementName isEqualToString:@"h1"]){

[self.currentItem setValue:[NSString stringWithString:self.xmlValue] forKey:elementName];

}

else if([elementName isEqualToString:@"p"]){

[self.currentItem setValue:[NSString stringWithString:self.xmlValue] forKey:elementName];

}

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

NSUInteger row = [indexPath row];

NSDictionary *dt = [self.xmlList objectAtIndex:row];

cell.textLabel.text = [NSString stringWithFormat:@"%@-%@", [dt objectForKey:@"h1"], [dt objectForKey:@"p"]];

return cell;

}


'Object-C' 카테고리의 다른 글

MoviePlayer  (0) 2010.10.09
MapView  (0) 2010.10.09
SQLITE  (0) 2010.10.08
CoreData  (0) 2010.10.07
archiving  (0) 2010.10.07
#include "/user/include/sqlite3.h"

-(NSString *) dataPath
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
return [documentDirectory stringByAppendingFormat:@"data.sqlite3""];
}

//applicationDidFinishLaunching 에서 호출 . Table 이 없으면 생성
-(void)createData{
if(sqlite3_open([[self dataPath] UTF8Strin],  &database) != SQLITE_OK){
sqlite3_close(database);
}

char *createSQL = "Create table if not exists address(name text, addr text, tel text, memo text);";

//DDL
if(sqlite3_exec(database, createSQL) != SQLITE_OK)
{
sqlite3_close(database);
}
sqlite3_close(database);
}

//화면이 갱신될때마다 호출
-(void)viewWillAppear:(BOOL) animated{
array = [[NSMutableArray alloc] init];

if(sqlite3_open([[self dataPath] UTF8String], &databae) != SQLITE_OK){
sqlite3_close(database);
}

NSString *selectSQL = @"select * from address";
sqlite3_stmt *stmt; //SQL구문을 컴파일한 바이너리 정보를 담은 구조체

//DML
//sqlite3_prepare_v2 : SQL문을 컴파일해서 sqlite3_stmt 로 만들어줌
if(sqlite3_prepare_v2(database, [selectSQL UTF8String], -1, stmt, nil) == SQLITE_OK){
while(sqlite3_step(stmt) == SQLITE_ROW){
char *nameData = (char *)sqlite3_column_text(stmt, 0);
char *addrData = (char *)sqlite3_column_text(stmt, 1);
char *telData = (char *)sqlite3_column_text(stmt, 2);
char *memoData = (char *)sqlite3_column_text(stmt, 3);

NSString *nameValue = [[NSString alloc] initWithUTF8String:nameData];
NSString *addrValue = [[NSString alloc] initWithUTF8String:addrData];
NSString *telValue = [[NSString alloc] initWithUTF8String:telData];
NSString *memoValue = [[NSString alloc] initWithUTF8String:memoData];

NSDictionary *row = [[NSDictionary alloc] initWithObjectAndKeys:nameValue, @"name", addrValue, @"addr",  telValue, @"tel", memoValue, @"memo", nil];
[array addObject:row];
[row release];
[nameValue release];
[addrValue release];
[telValue  release];
[memoValue release];

}
sqlite3_finalize(stmt);
}
sqlite3_close(database);
[self.tableView reloadData];

[super viewWillAppear:animated];
}

//EditController.m
-(void)viewWillAppear:(BOOL)animated{
txtName.text = @"";
txtAddr.text = @"";
txtTel.text = @"";
txtMemo.text = @"";

if([sMode isEqualToString:@"편집"]){
if(sqlite3_open([[self dataPath] UTF8String], &database) != SQLITE_OK){
sqlite3_close(database);
}

char *selectSQL = "select * from address where name = ? ";
sqlite3_stmt *stmt;

if(sqlite3_prepare_v2(adtabase, selectSQL, -1, stmt, nil) == SQLITE_OK){
sqlite3_bind_text(stmt, 1, [sName UTF8String], -1,  SQLITE_TRANSIENT);

while(sqlite3_step(stmt) == SQLITE_ROW){
char *nameData = (char *)sqlite3_column_text(stmt, 0);
char *addrData = (char *)sqlite3_column_text(stmt, 1);
char *telData = (char *)sqlite3_column_text(stmt, 2);
char *memoData = (char *)sqlite3_column_text(stmt, 3);

NSString *nameValue = [[NSString alloc] initWithUTF8String:nameData];
txtName.text = nameValue;
[nameData release];

NSString *addrValue = [[NSString alloc] initWithUTF8String:addrData];
txtAddr.text = addrValue;
[addrData release];

....
....
}
sqlite3_finallize(stmt);
}
sqlite3_close(database);
}
[super viewWillAppear:animated];
}

-(void)Save{
if(sqlite3_open([[self dataPath] UTF8String], &database) != SQLITE_OK){
sqlite3_close(database);
}

if([sMode isEqualToString:@"추가"]){ 
char *insertSQL = "insert into address(name, addr, tel, memo) values (? , ?, ?, ?);";
sqlite3_stmt *stmt;

if(sqlite3_prepare_v2(database, insertSQL, -1, stmt, nil) == SQLITE_OK)
{
sqlite3_bind_text(stmt, 1, [txtName.text UTF8String], -1_;
sqlite3_bind_text(stmt, 2, [txtAddr.text UTF8String], -1_;
sqlite3_bind_text(stmt, 3, [txtTel.text UTF8String], -1_;
sqlite3_bind_text(stmt, 4, [txtMemo.text UTF8String], -1_;
}

if(sqlite3_step(stmt) != SQLITE_DONE){
sqlite3_close(database);
}

sqlite3_finalize(stmt);
}
else if([sMode isEqualToString:@"편집"]){
NSString *updateSQL = [NSString stringWithFormat:@"Update address name = '%@', addr = '%@', tel = '%@', memo = '%@' where name = '%@'",
txtName.text, txtAddr.text, txtTel.text, txtMemo.text, sName];

sqlite3_stmt *stmt;
if(sqlite3_prepare_v2(database, updateSQL, -1, stmt, nil) != SQLITE_OK)
{
sqlite3_close(database);

if(sqlite3_step(stmt) != SQLITE_DONE){
sqlite3_close(database);
}

sqlite3_finalize(stmt);
}

sqlite3_close(database);
[self.navigationController popViewControllerAnimated:YES];
}

'Object-C' 카테고리의 다른 글

MapView  (0) 2010.10.09
XML  (0) 2010.10.09
CoreData  (0) 2010.10.07
archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
 데이타베이스 코어데이타   
데이타베이스 자체 관리객체 컨텍스트(Managed Object Context)  관리객체를 담는 그릇 
테이블 구조(스키마)  엔티티 (NSEntityDescription)   
테이블 구조를 이루는 세부컬럼 정보 프로퍼티 (Property)   
테이블 내의 하나의 레코드 관리객체 (Managed Object)   
SQL문 (예: select * from) 갬색 요청(Fetch Request)   
SQL 조건문 (where age > 20) 조건 서술(Predicate)   
저장소 관리자 저장소 관리자 (Persistent Store Coordinator) 컨텍스트 내용을 파일이나 DB에 저장하는 객체 




//프로그램종료시 저장
-(void)applicationWillTerminate:(NSNotification *)notification{
coreDataAppDelegate *appDelegate = [UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSError *error;

for(int i=1;i<=3;i++)
{
NSString *fieldName = [NSString stringWithFormat:@"line%d",i];
UITextField *field = [self valueForKey:fieldName];

NSFetchRequest *request = [NSFetchRequest alloc] init];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Line" inManagedObjectContext:context];
[request setEntity:entity];

NSPredicate *pred = [NSPredicate predicateWithFormat:@"(lineNum = %d)", i];
[request setPredicate:pred];

NSManagedObject *theLine = nil;

NSArray *array = [context executeFetchRequest:request error:&error];

if([array count] > 0)
theLine = [array objectAtIndex:0];
else
theLine = [NSEntityDescription insertNewObjectForEntityForName:@"Line"                    inManagedObjectContext:context];

[theLine setValue:[NSNumber numberWithInt:i] forKey:@"lineNum"];
[theLine setValue:field.text forKey:@"lineText"];

[request release];
}

[context save:&error];
}

-(void)ViewDidLoad{
coreDataAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];

NSFetchRequest *request = [[NSFetchRequest alloc] init];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Line" inManagedObjectContext:context];
[request setEntioty:entity];

NSError *error;

NSArray *array = [context executeFetchRequest:request error:&error];

for(ManagedObject *oneObject in array)
{
NSNumber *lineNum = [oneObject valueForKey:@"lineNum"];
NSString *lineText = [oneObject valueForKey:@"lineText"];

NSString *field  = [NSString stringWithFormat:@"line%d", lineNum];
UITextField *txtField = [self valueForKey:field];

txtField.text = lineText;
}
[request release];

UIApplication *app = [UIApplication sharedApplication];
[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:app];

}

'Object-C' 카테고리의 다른 글

XML  (0) 2010.10.09
SQLITE  (0) 2010.10.08
archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
imagePicker  (0) 2010.10.07
//archivingData.m

-(id) initWithCoder:(NSCoder *)aDecoder

{

if (self = [super init]) {


self.email = [aDecoder decodeObjectForKey:@"email"];

self.pwd =[aDecoder decodeObjectForKey:@"pwd"];

}

return self;

}


-(void) encodeWithCoder:(NSCoder *)aCoder

{

[aCoder encodeObject:email forKey:@"email"];

[aCoder encodeObject:pwd forKey:@"pwd"];

}


//viewController.m

- (void)viewDidLoad {

NSString *path = [self DataPath];

if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {

NSMutableData *data = [[NSMutableData alloc] initWithContentsOfFile:path];

NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];

archivingData *archiv = [unArchiver decodeObjectForKey:@"data"];

[unArchiver finishDecoding];

txtEmail.text = archiv.email;

txtPwd.text = archiv.pwd;

[data release];

[unArchiver release];

}

UIApplication *sharedApp = [UIApplication sharedApplication];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:sharedApp];

    [super viewDidLoad];

}



-(void)applicationWillTerminate:(NSNotification *)notif

{

archivingData *archiv = [[archivingData alloc] init];

archiv.email = txtEmail.text;

archiv.pwd = txtPwd.text;

NSMutableData *data = [[NSMutableData alloc] init];

NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];

[archiver encodeObject:archiv forKey:@"data"];

[archiver finishEncoding];

[data writeToFile:[self DataPath] atomically:YES];

[archiv release];

[data release];

[archiver release];

}


-(NSString *)DataPath

{

NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *directory = [path objectAtIndex:0];

return [directory stringByAppendingFormat:@"archivingData"];

}

//Document 디렉토리안에 저장되는게 아니라 DocumentsarchivingData 로 저장됨

'Object-C' 카테고리의 다른 글

SQLITE  (0) 2010.10.08
CoreData  (0) 2010.10.07
pickerView  (0) 2010.10.07
imagePicker  (0) 2010.10.07
pageControl  (0) 2010.10.07
-(void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForREsource:@"data" ofType:@"plist"];

NSDictionary *dic = [[NSDIctionary alloc] initWithContentsOFFile:path];
self.subName = dic;
[dic release];

NSArray *keys = [[self.subName allKeys] sortedArrayUsingSelector:@selector(compare:)];
self.pickerData = keys;

NSString *selectedData = [self.pickerData objectAtIndex:0];
NSArray *array = [self.subName objectForKey:selectedData];
self.subData = array;

}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(component == 0)
{
NSString *selectedData = [self.pickerData objectAtIndex:row];
NSArray *array = [self.subName objectForKey:selectedData];
self.subData = array;

[picker selectRow:0 inComponent:1 animated:YES];
[picker reloadComponent:1];
}
}

'Object-C' 카테고리의 다른 글

CoreData  (0) 2010.10.07
archiving  (0) 2010.10.07
imagePicker  (0) 2010.10.07
pageControl  (0) 2010.10.07
ScrollView  (0) 2010.10.07
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

-(void)btnList:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
imagePicker.delegate = self;

imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

//imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera

[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo
{
imgView.image = selectedImage;
[self dismissModalViewControllerAnimated:YES];
}

'Object-C' 카테고리의 다른 글

archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
pageControl  (0) 2010.10.07
ScrollView  (0) 2010.10.07
customCell  (0) 2010.10.07

- (void)viewDidLoad {

    [super viewDidLoad];

for(int i=0;i<2;i++)

{

UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"T%d.gif", i+1]];

UIImageView *imgView = [[UIImageView alloc] initWithImage:img];

imgView.frame = CGRectMake(scrollView.frame.size.width * i, 0, scrollView.frame.size.width, scrollView.frame.size.height);

[scrollView addSubview:imgView];

[img release];

}

[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width * 2, scrollView.frame.size.height)];

paging.numberOfPages = 2;

}


-(void)scrollViewDidScroll:(UIScrollView *)sender{

CGFloat pageWidth = scrollView.frame.size.width;

int page = floor((scrollView.contentOffset.x - pageWidth/2) / pageWidth) + 1;

paging.currentPage = page;

}

'Object-C' 카테고리의 다른 글

archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
imagePicker  (0) 2010.10.07
ScrollView  (0) 2010.10.07
customCell  (0) 2010.10.07
-(void)viewDidLoad
{
UIImage *img = [UIImage imageNamed:@"IMG_01.jpg"];
imageView.image = img;
CGSize imgSize = [img size];

[scrollview setContentSize:imgSize];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

return imgView;

}



http://www.ddandongne.com/ddanhome/zbuilder/?mid=iphone_sdk&page=1&document_srl=2234

'Object-C' 카테고리의 다른 글

archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
imagePicker  (0) 2010.10.07
pageControl  (0) 2010.10.07
customCell  (0) 2010.10.07

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    

    static NSString *CellIdentifier = @"Cell";

    

    customCell *cell = (customCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

//        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

NSArray *arr = [[NSBundle mainBundleloadNibNamed:@"customCell" owner:nil options:nil];

cell = [arr objectAtIndex:0];

    }

    

// Configure the cell.

NSString *key = [self.keys objectAtIndex:[indexPath section]];

NSInteger row = [indexPath row];

cell.lblNo.text = [[NSString allocinitWithFormat:@"%d", row +1];

cell.lblText.text = [[self.items objectForKey:key] objectAtIndex:[indexPath row]];

    return cell;

}

'Object-C' 카테고리의 다른 글

archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
imagePicker  (0) 2010.10.07
pageControl  (0) 2010.10.07
ScrollView  (0) 2010.10.07

+ Recent posts