数値

프로그래밍 2011. 7. 7. 16:32

数値

コンピュータは計算が得意であるということは、誰もが知ってる常識です
当然、プログラムのソースの大部分は計算と制御で埋め尽くされるでしょう

プログラムでは、数値や文字列を直接記述したものをリテラルと呼びます
データには様々ながあり、代表どころでは整数、浮動小数、文字などがあります
数値を使った演算は主に整数型のリテラルで表現することができます

C#の整数型は、0 ~ 9 を使った10進数と、0 ~ F を使った16進数を使用できます
10進数はそのまま、16進数の場合は数値の前に 0x プリフィックスを付加する必要があります
なお、16進数のA~Fは小文字で指定しても問題はありません
class Test {
	static void Main() {
		System.Console.WriteLine(1983);
		System.Console.WriteLine("-ビル・ゲイツが Windows を発表-");

		System.Console.WriteLine(0x7C1);
		System.Console.WriteLine("-Microsoft が Windows をリリース-");
	}
}
このプログラムでは WriteLine() メソッドに 1983 という10進整数値と
7C1 という16進整数値(10進数の 1985)を渡しています
WriteLine() メソッドは、この数値を文字列に変換しコンソールに出力します

ただし、16進数も10進数も機械語では2進数なので
これらはコンパイラが扱うものであり、機械語レベルでは同じ扱いです
そのため、文字列に変換して表示した時は10進数で表示されてしまいます


実数値

プログラムが小数も扱う場合は、整数型ではなく実数型を使用します
実数リテラルは整数と違い10進数しか扱えないので注意してください

実数型は、10進整数部と小数以下の10進指数部からなります
プログラムでは小数を浮動小数点と呼ばれる方法で表現します
基本的には、数学同様に 整数部.小数部 という形で表せます
ただし浮動小数は、アンダーフローや丸め誤差と呼ばれる誤差が発生するので
その扱いにはある程度のコンピュータ科学知識が必要になることがあります

実数型は、指数表記 e または E を使用することができます
指数表記は10の累乗を表すもので 4e3 で 4000 というように表すことができます
class Test {
	static void Main() {
		System.Console.WriteLine(42.195);
		System.Console.WriteLine(0.3e-2);		
	}
}
このプログラムも、実数を問題なくコンソールに出力してくれることでしょう


文字と文字列

C# の文字は様々な国の言語を表現できる国際的な Unicode を使用しています
これは、近年 Java や Windows NT などにも積極的にとり入れられている重要な文字コードで
アプリケーション開発の国際化の時代に非常に貢献している技術です

Unicode は 2 バイト文字であり、C# は1文字に2バイトの容量を使用します
これは、C/C++ の ASCII に比べて大きく異なる点の一つです

文字はシングルクォーテーション 'で囲むことで表現できます
文字列と違い、文字型は2バイトまでと定められているため1文字しか表せません
class Test {
	static void Main() {
		System.Console.WriteLine('A');
		System.Console.WriteLine('1');
	}
}
このプログラムは WriteLine() メソッドに文字を渡して表示します
注意してほしいのですが '1' というのは数値ではなく文字型としての 1 です
表示された時は 1 としかありませんが、データ型が違うというのは重要です
この後に紹介する計算などの時には、データ型の違いは重要な項目になります

文字列は、前回紹介したようにダブルクォーテーション " で囲むことで表現できました
しかし、改行などは文字列の中で表現できませんでした
改行やタブのような特殊な文字はエスケープ文字 \と呼ばれる文字で表現します

エスケープ文字は \ で始まりその後に何らかの文字などを付加します
これをエスケープシーケンスと呼び、次のものがあります

エスケープシーケンス 説明 Unicode
\' シングルクォーテーション 0x0027
\" ダブルクォーテーション 0x0022
\\ 円マーク 0x005C
\0 null 0x0000
\a アラート 0x0007
\b バックスペース 0x0008
\f 改ページ 0x000C
\n 改行 0x000A
\r キャリッジリターン 0x000D
\t 水平タブ 0x0009
\v 垂直タブ 0x000B
\x16進数 16進エスケープシーケンス

これらのエスケープシーケンスを文字、または文字列に含ませて出力すると
それぞれのエスケープシーケンスの意味する文字を出力することができます
これを使用すれば、文字列内に " を表示させることが出きるようになります

ただし、文字列において \ に続く文字は上のいずれかのエスケープシーケンスである必要があります
class Test {
	static void Main() {
		System.Console.WriteLine("Kitty on your lap\nTokyo mew mew");
		System.Console.WriteLine("\"Nekoneko Zoo\"");
		System.Console.WriteLine("\x005C\x0009\x005C");
	}
}
これをコンパイルして実行すると、次のようになります
Kitty on your lap
Tokyo mew mew
"Nekoneko Zoo"
\       \
このように、改行コードやタブをエスケープシーケンスで表現できます
これは C/C++ の経験者であればお馴染みのものでしょう

C# は、上のように " " で囲まれた文字列を標準文字列と呼びます
これに対し、逐語的文字列と呼ばれる便利な文字列表現もあります

逐語的文字列は、標準文字列と違い " 以外の全ての文字を文字列内に指定できます
標準文字列では文字列中に改行することはできませんでしたが
逐語的文字列はタブ、改行、エスケープ文字などが全てそのまま解釈されます
ただし、逐語的文字列内で " を表現したい場合は "" と記述します

逐語的文字列は @" ではじまり " で終わります
class Test {
	static void Main() {
		System.Console.WriteLine(
@"\Kitty on your lap\
\n	Tokyo mew mew	\t
""Di Gi Charat"""
		);
	}
}
これを実行すると、次のような文字列が出力されます
\Kitty on your lap\
\n	Tokyo mew mew	\t
"Di Gi Charat"
これを見れば、エスケープ文字は解釈されずにそのまま解釈され
タブや改行も表現されていることが確認できます


Posted by 김반장78
,
별 내용 아닌데 정보가 없어 한참 고생하기

1. 옵션에 클래스패스 선택 - 폴더 추가선택 - 컴파일된 클래스폴더의 루트폴더를 선택 - 저장

2.레포트쿼리 선택 - JavaBean탭 선택 - 클래스명에 해당 클래스명 직접 입력 - 속성취득버튼 클릭

'프로그래밍' 카테고리의 다른 글

数値  (0) 2011.07.07
[펌] 자바 파일 입출력시 글자깨짐 문제  (0) 2010.12.27
[JAVA] XmlWriter.java  (0) 2010.12.10
C# 과 JAVA 의 이스케이프 코드 차이점  (0) 2010.12.09
[NetBeans] setDisable() 관련 문제  (0) 2010.11.25
Posted by 김반장78
,
import java.io.IOException;
import java.io.Writer;

import java.util.Stack;

import com.generationjava.io.WritingException;

/**
* Makes writing XML much much easier.
*
* @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
* @version 0.1
*/

public class XmlWriter {

    private Writer writer;      // underlying writer
    private Stack stack;        // of xml entity names
    private StringBuffer attrs; // current attribute string
    private boolean empty;      // is the current node empty
    private boolean closed;     // is the current node closed...

    /**
     * Create an XmlWriter on top of an existing java.io.Writer.
     */

    public XmlWriter(Writer writer) {
        this.writer = writer;
        this.closed = true;
        this.stack = new Stack();
    }

    /**
     * Begin to output an entity.
     *
     * @param String name of entity.
     */

    public XmlWriter writeEntity(String name) throws WritingException {
        try {
            closeOpeningTag();
            this.closed = false;
            this.writer.write("<");
            this.writer.write(name);
            stack.add(name);
            this.empty = true;
            return this;
        } catch (IOException ioe) {
            throw new XmlWritingException(ioe);
        }
    }

    // close off the opening tag
    private void closeOpeningTag() throws IOException {
        if (!this.closed) {
            writeAttributes();
            this.closed = true;
            this.writer.write(">");
        }
    }

    // write out all current attributes
    private void writeAttributes() throws IOException {
        if (this.attrs != null) {
            this.writer.write(this.attrs.toString());
            this.attrs.setLength(0);
            this.empty = false;
        }
    }

    /**
     * Write an attribute out for the current entity.
     * Any xml characters in the value are escaped.
     * Currently it does not actually throw the exception, but
     * the api is set that way for future changes.
     *
     * @param String name of attribute.
     * @param String value of attribute.
     */

    public XmlWriter writeAttribute(String attr, String value) throws WritingException {

        // maintain api
        if (false) throw new XmlWritingException();

        if (this.attrs == null) {
            this.attrs = new StringBuffer();
        }
        this.attrs.append(" ");
        this.attrs.append(attr);
        this.attrs.append("=\"");
        this.attrs.append(escapeXml(value));
        this.attrs.append("\"");
        return this;
    }

    /**
     * End the current entity. This will throw an exception
     * if it is called when there is not a currently open
     * entity.
     */

    public XmlWriter endEntity() throws WritingException {
        try {
            if(this.stack.empty()) {
                throw new XmlWritingException("Called endEntity too many times. ");
            }
            String name = (String)this.stack.pop();
            if (name != null) {
                if (this.empty) {
                    writeAttributes();
                    this.writer.write("/>");
                } else {
                    this.writer.write("</");
                    this.writer.write(name);
                    this.writer.write(">");
                }
                this.empty = false;
            }
            return this;
        } catch (IOException ioe) {
            throw new XmlWritingException(ioe);
        }
    }

    /**
     * Close this writer. It does not close the underlying
     * writer, but does throw an exception if there are
     * as yet unclosed tags.
     */

    public void close() throws WritingException {
        if(!this.stack.empty()) {
            throw new XmlWritingException("Tags are not all closed. "+
                "Possibly, "+this.stack.pop()+" is unclosed. ");
        }
    }

    /**
     * Output body text. Any xml characters are escaped.
     */

    public XmlWriter writeText(String text) throws WritingException {
        try {
            closeOpeningTag();
            this.empty = false;
            this.writer.write(escapeXml(text));
            return this;
        } catch (IOException ioe) {
            throw new XmlWritingException(ioe);
        }
    }

    // Static functions lifted from generationjava helper classes
    // to make the jar smaller.
   
    // from XmlW
    static public String escapeXml(String str) {
        str = replaceString(str,"&","&amp;");
        str = replaceString(str,"<","&lt;");
        str = replaceString(str,">","&gt;");
        str = replaceString(str,"\"","&quot;");
        str = replaceString(str,"'","&apos;");
        return str;
    } 

    // from StringW
    static public String replaceString(String text, String repl, String with) {
        return replaceString(text, repl, with, -1);
    } 
    /**
     * Replace a string with another string inside a larger string, for
     * the first n values of the search string.
     *
     * @param text String to do search and replace in
     * @param repl String to search for
     * @param with String to replace with
     * @param n    int    values to replace
     *
     * @return String with n values replacEd
     */

    static public String replaceString(String text, String repl, String with, int max) {
        if(text == null) {
            return null;
        }

        StringBuffer buffer = new StringBuffer(text.length());
        int start = 0;
        int end = 0;
        while( (end = text.indexOf(repl, start)) != -1 ) {
            buffer.append(text.substring(start, end)).append(with);
            start = end + repl.length();

            if(--max == 0) {
                break;
            }
        }
        buffer.append(text.substring(start));

        return buffer.toString();
    }             

    // Two example methods. They should output the same XML:
    // <person name="fred" age="12"><phone>425343</phone><bob/></person>
    static public void main(String[] args) throws WritingException {
        test1();
        test2();
    }
    static public void test1() throws WritingException {
        Writer writer = new java.io.StringWriter();
        XmlWriter xmlwriter = new XmlWriter(writer);
        xmlwriter.writeEntity("person").writeAttribute("name", "fred").writeAttribute("age", "12").writeEntity("phone").writeText("4254343").endEntity().writeEntity("bob").endEntity().endEntity();
        xmlwriter.close();
        System.err.println(writer.toString());
    }
    static public void test2() throws WritingException {
        Writer writer = new java.io.StringWriter();
        XmlWriter xmlwriter = new XmlWriter(writer);
        xmlwriter.writeEntity("person");
        xmlwriter.writeAttribute("name", "fred");
        xmlwriter.writeAttribute("age", "12");
        xmlwriter.writeEntity("phone");
        xmlwriter.writeText("4254343");
        xmlwriter.endEntity();
        xmlwriter.writeEntity("bob");
        xmlwriter.endEntity();
        xmlwriter.endEntity();
        xmlwriter.close();
        System.err.println(writer.toString());
    }
}

C#에는 있는데 왜 자바에는 없는거냐..ㅡ.ㅡ



Posted by 김반장78
,
  • Escape sequences

    inside char and String literals include:
    ' ' space
    '\u003f' Unicode hex, (must be exactly 4 digits to give a 16-bit Unicode number ). \u2007 is Figure Space, a space as wide as a digit, to help in aligning numbers.
    '\n' newline, ctrl-J (10, x0A)
    '\b' backspace, ctrl-H (8, 0x08)
    '\f' formfeed, ctrl-L (12, 0x0C)
    '\r' carriage return, ctrl-M (13, 0x0D)
    '\t' tab, ctrl-I (9, 0x09)
    '\\' backslash,
    '\'' single quote (optional inside " "),
    '\"' double quote (optional inside ' '),
    '\377' octal (must be exactly 3 digits. You can get away with fewer, but then you create an ambiguity if the character following the literal just happens to be in the range 0..7.). This lets you get at only the 8-bit characters in the range 0..377 octal or 0..255 decimal or 0..255 decimal, which still gives you 16-bit Unicode.
    \007 bel, ctrl-G (7, 0x07)
    \010 backspace, ctrl-H (8, 0x08)
    \013 vt vertical tab, ctrl-K (11, 0x0B)
    \032 sub (used in DOS/CPM as eof), ctrl-Z (26, 0x1A)
    \033 esc ctrl-^ (27, 0x1B)
  •  

  • C# Escape sequences


  • \' - single quote, needed for character literals
  • \" - double quote, needed for string literals
  • \\ - backslash
  • \0 - Unicode character 0
  • \a - Alert (character 7)
  • \b - Backspace (character 8)
  • \f - Form feed (character 12)
  • \n - New line (character 10)
  • \r - Carriage return (character 13)
  • \t - Horizontal tab (character 9)
  • \v - Vertical quote (character 11)
  • \uxxxx - Unicode escape sequence for character with hex value xxxx
  • \xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx)
  • \Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)
  • C# \xn[n][n][n] 의 추가 설명
    16진수 이스케이프 시퀀스에는 다양한 자릿수의 16진수를 사용할 수 있습니다. 문자열 리터럴 "\x123"에는 16진수 값이 123인 문자 하나가 포함됩니다. 16진수 값이 12인 문자 다음에 문자 3이 오는 문자열을 만들려면 "\x00123"이나 "\x12" + "3"을 사용하십시오.

    Posted by 김반장78
    ,
    강좌라기 보다는 내가 배우면서 찾아본 자료는 최신버전의 강좌가 없어서 
    설정이나 메뉴구성이 미묘하게 다른 부분에 다른초보분들이 망설이지 않고 따라할수 있게..
    이건 핑계고 걍 이런거라도 남기면서 하면 좀더 재미있을까 하는...

    이번편의 목적은 윈도우 베이스의 어플에 뷰를 추가하는 과정을 해봄으로서 뷰나 기타 라이브러리의 추가에
    익숙해지기 위해서 이다.

    실행환경은 Xcode 3.2.4

    순서는
    1. 프로젝트 생성
    2. 클래스파일 생성
    3. 클래스파일 코딩
    4. 인터페이스 빌더 작업
    5. 완성

    1. 프로젝트 생성
    새프로젝트 생성에서 Window-based Application  선택

    2. 클래스 파일 생성
    생성하고자 하는 폴더 위에서 마우스 우클릭후 Add - New File.. 선택

    UIViewController 를 선택

    위에 클래스명을 적당히 적어주고 바로 밑의 Also Create 를 체크한다
    언제나 그렇듯 명명은 중요하다 적당히 잘 적어넣자.
    피니쉬 버튼을 누르면 3개의 파일이 생성된다.
    그중 확장자가 xib인 화일은 이름을 다시 바꿔주는것도 좋을듯 하다. 혼동되기 쉽다.
    그리고 폴더도 class 폴더보단 Resources 폴더가 더 어울리는 것같다. 옮겨주자.

    3. 소스 수정
    Project명이 Test라면 프로젝트 생성시에 TestAppDelegate.h TestAppDelegate.m 파일이 생성되었을것이다.

    TestAppDelegate.h  

    ------------------------------------------------------------------

    #import <UIKit/UIKit.h>

    @class WelcomeCtr;


    @interface TestAppDelegate : NSObject <UIApplicationDelegate> {

        UIWindow *window;

        WelcomeCtr *welcomeCtr; //추가

    }


    @property (nonatomic, retain) IBOutlet UIWindow *window;

    @property (nonatomic, retain) IBOutlet WelcomeCtr *welcomeCtr;  //추가


    @end


    ------------------------------------------------------------------


    TestAppDelegate.m


    ------------------------------------------------------------------


    #import "TestAppDelegate.h"

    #import "WelcomeCtr.h"


    @implementation TestAppDelegate


    @synthesize window;

    @synthesize welcomeCtr;   //추가


    #pragma mark -

    #pragma mark Application lifecycle


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

        

        // Override point for customization after application launch.

    [window addSubview:welcomeCtr.view];   //추가

        [window makeKeyAndVisible];

        

        return YES;

    }



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

        /*

         Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

         Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

         */

    }



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

        /*

         Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 

         If your application supports background execution, called instead of applicationWillTerminate: when the user quits.

         */

    }



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

        /*

         Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.

         */

    }



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

        /*

         Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

         */

    }



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

        /*

         Called when the application is about to terminate.

         See also applicationDidEnterBackground:.

         */

    }



    #pragma mark -

    #pragma mark Memory management


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

        /*

         Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.

         */

    }



    - (void)dealloc {

    [welcomeCtr release];   //추가

        [window release];

        [super dealloc];

    }



    @end


    ------------------------------------------------------------------


    4. 인터페이스 빌더 작업

    Overview창에서 MainWindow.xib 파일을 더블클릭하면 인터페이스 빌더가 실행된다
    라이브러리창에서 View Controller 를 끌어다가 MainWindow.xib창에다 놓는다.
    라이브러리창이 보이지 않는다면 인터페이스 빌더 상단 메뉴에서 View - Library를 선택한다.
    이작업은 생성한 뷰객체를 넣을수 있는 공간을 마련한다고 생각하면 될듯하다.


    생성된 View Controller 객체를 클릭후 상단의 파란색 Inspector 버튼을 클릭하면 오른쪽의 어트리뷰트창이 열린다.
    첫번째 탭을 선택후 NIB Name 을 생성한 xib 파일명으로 선택해준다


    마지막 탭을 선택후 Class에 자신이 생성한 클래스 파일을 선택해준다.

    마지막 작업이다.
    스샷에는 Finder App Delegate 라고 되있지만 자신의 프로젝트명 App Delegate 를 선택하고 마우스 우클릭을 하면
    밑에 보이는 검은색 팝업이 열린다.
    welcomeCtr 옆의 속이 비어있는 원을 클릭후 오른쪽의 Welcome Ctr 에다가 끌어다 놓는다.


    잘 되었다면 아래의 화면처럼 되었을 것이다.


    이걸로 끝이다 
    별내용 아닌데 길어졌다.

    아이폰에서 실행시켜보면 새하얀 화면이 나오는것을 확인할수 있다.
    이작업이 귀찮다면 가장위의 화면에서 View-base 앱을 선택해주면 지금까지의 작업이 완료된 프로젝트가 생성된다. 
    먼짓한거야...
    Posted by 김반장78
    ,
    구글링을 통해 찾아냈다.
    거의 예전 버전밖에 없어서 고생..

    실행기반은 Xcode 3.2.4 iPhone 4.1

    인증서 만들기

    1. Open up Keychain Access in Applications>Utilities.
    2. Go to Keychain Access>Certificate Assistant>Create a Certificate.
    3. For ‘Name’, type: iPhone Pwned Developer
    4. For ‘Identity Type’, leave it as ‘Self Signed Root’.
    5. For ‘Certificate Type’, choose ‘Code Signing’.
    6. Check the box for ‘Let me override defaults’.
    7. Click on Continue, and in the popup box that comes up.
    8. Type in any number under ‘Serial Number’.
    9. Leave ‘Validity Period (days)’ alone.
    10. Click on Continue.
    11. Fill in the details with whatever you want (not really necessary).
    12. Click on Continue.
    13. Click on Continue for the rest of the dialog boxes.

    Xcode 설정

    1. Open /Developer/Platforms/iPhoneOS.platform/Info.plist with Property List Editor.
    2. Look for all ‘XCiPhoneOSCodeSignContext’ VALUES. Replace that with ‘XCCodeSignContext’. There should be two or three to replace.
    3. Save the file.
    4. Restart Xcode, and build your app for a device.

    Open up your project settings in Xcode (Project>Edit Project Settings), go to the Build tab, and under ‘Code Signing’, extend ‘Code Signing Identity’, and choose ‘iPhone Pwned Developer’, which should be the name of the certificate you just made above.

    스샷은 필요없지 싶다.
    버전하나 올라갈때마다 화면이 바껴서 크게 소용없을듯..

    Posted by 김반장78
    ,
    우회해서 짜는 방법이 여렀있었으나 가장 마음에 든건..
    CardLayout 활용

    ....
    Container ct;

    CardLayout card;
    JPanel card1;
    JPanel card2;

    ct.add(card1, "card1");
    ct.add(card2, "card2");

    card.show(ct, "card1");
    ....




    Posted by 김반장78
    ,

    #import "AddCityController.h"

    #import "CityGuideDelegate.h"

    #import "RootController.h"

    #import "City.h";


    @implementation AddCityController


    #pragma mark ViewController Methods


    - (void)didReceiveMemoryWarning {

    // Releases the view if it doesn't have a superview.

        [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.

    }


    - (void)viewDidLoad {

    self.title = @"New City";

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveCity:)];

    cityPicture = [UIImage imageNamed:@"QuestionMark.jpg"];

    pickerController = [[UIImagePickerController alloc] init];

    pickerController.allowsEditing = NO;

    pickerController.delegate = self;

    pickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;


    }


    - (void)viewDidUnload {

    // Release any retained subviews of the main view.

    // e.g. self.myOutlet = nil;

    }



    - (void)dealloc {

    [tableView release];

    [nameCell release];

    [pictureCell release];

    [descriptionCell release];

    [pickerController release];

        [super dealloc];

    }


    #pragma mark Instance Methods

    - (void)saveCity:(id)sender {

    CityGuideDelegate *delegate = (CityGuideDelegate *)[[UIApplication sharedApplication] delegate];

    NSMutableArray *cities = delegate.cities;

    UITextField *nameEntry = (UITextField *)[nameCell viewWithTag:777];

    UITextView *descriptionEntry = (UITextView *)[descriptionCell viewWithTag:777];

    if ( nameEntry.text.length > 0 ) {

    City *newCity = [[City alloc] init];

    newCity.cityName = nameEntry.text;

    newCity.cityDescription = descriptionEntry.text;

    newCity.cityPicture = cityPicture;

    [cities addObject:newCity];

    RootController *viewController = delegate.viewController;

    [viewController.tableView reloadData];

    }

    [delegate.navController popViewControllerAnimated:YES];

    }


    - (IBAction)addPicture:(id)sender {

    UITextField *nameEntry = (UITextField *)[nameCell viewWithTag:777];

    [nameEntry resignFirstResponder];

    [self presentModalViewController:pickerController animated:YES];

    }


    #pragma mark UIImagePickerController Methods


    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [self dismissModalViewControllerAnimated:YES];


    cityPicture = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    UIImageView *pictureView = (UIImageView *)[pictureCell viewWithTag:777];

    pictureView.image = cityPicture;

    [tableView reloadData];

    }


    #pragma mark UITableViewDataSource Methods


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

    UITableViewCell *cell = nil;

    if( indexPath.row == 0 ) {

    cell = nameCell;

    } else if ( indexPath.row == 1 ) {

    UIImageView *pictureView = (UIImageView *)[pictureCell viewWithTag:777];

    pictureView.image = cityPicture;

    cell = pictureCell;

    } else {

    cell = descriptionCell;

    }

    return cell;

    }


    - (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section {

    return 3;

    }


    #pragma mark UITableViewDelegate Methods


    - (CGFloat)tableView:(UITableView *)tv heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    CGFloat height;

    if( indexPath.row == 0 ) {

    height = 44;

    } else if( indexPath.row == 1 ) {

    height = 83;

    } else {

    height = 279;

    }

    return height;

    }


    @end


    Posted by 김반장78
    ,

    위 사진처럼 시뮬레이터 버전 수정해 주면 된다.

    맥에서는 티스토리 사진 안올라가 지더니 갑자기 되네 고친건가..,
    조금더 편하게 블로깅 할수 있을듯 ㅋ
    Posted by 김반장78
    ,

    한국에서 책이 도착했다

    조금 읽어 봤는데 연습하면서 느낀점이 바로 나오더라는..
    책은 잘산거 같다
    일년에 한두권 사는 책이 참고서 아니면 학습서이니..ㅡ.ㅡ
    Posted by 김반장78
    ,