Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: มีปัญหาเกี่ยวกับ iPhone programming

  1. #1


    มี error ที่ผมไม่เข้าใจอะครับ เข้าไปดูตาม link ได้เลยครับ ผมทำรูปไว้ให้ดูแล้ว

    http://cid-e109a68d00f7f282.spaces.l...m/default.aspx

    ช่วยทีนะครับ ขอบคุณครับ

  2. #2


    มี error ที่ผมไม่เข้าใจอะครับ เข้าไปดูตาม link ได้เลยครับ ผมทำรูปไว้ให้ดูแล้ว

    http://cid-e109a68d00f7f282.spaces.l...m/default.aspx

    ช่วยทีนะครับ ขอบคุณครับ

  3. #3
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    รับทราบครับเดียวแจ้งให้ วิทยากรทราบครับ

  4. #4
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    รับทราบครับเดียวแจ้งให้ วิทยากรทราบครับ

  5. #5
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    วิทยากรตอบให้แล้วนะครับ

    CGPoint มันประกาศเป็น structure (ในรูปแบบของภาษา c )

    struct CGPoint {
    CGFloat x;
    CGFloat y;
    };
    typedef struct CGPoint CGPoint;

    และเนื่องจากว่า CGPoint เป็นเพียงแค่ structure ไม่ได้เป็น class
    ที่สามารถประกาศ member data ในลักษณะของ property เหมือนอย่าง iButton
    ได้

    การเรียกใช้

    self.position // แบบนี้คือให้ self เรียก property ที่ชื่อว่า position
    อันนี้ถูก แต่
    self.position.x // แบบนี้คือให้ position เรียก property ที่ชื่อว่า x
    ซึ่งมันไม่มีจึงผิด


    วิธีการแก้ไข ( มีหลายแบบมาก แต่ผมจะแนะนำวิธีง่ายสุดให้ก่อน )

    ผมเข้าใจว่าน้องเค้าคงต้องการ จะเก็บค่า position ไว้ใน class ของ iButton
    ดังนั้นแล้ว เราเพียงแค่ประกาศ position ไม่ต้องเป็น pointer
    ก็จบแล้วครับ เพราะ position ไม่ได้เป็น class เป็นเพียงแค่ structure
    ภาษา c เท่านั้นเอง

    code ที่แก้ไขก็จะเป็น แบบนี้ครับ

    // .h

    @interface iButton : NSObject
    {
    CGPoint position;
    }


    การเรียกใช้ ก็เปลี่ยนจาก

    self.position.x ให้เป็น position.x แทน

  6. #6
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    วิทยากรตอบให้แล้วนะครับ

    CGPoint มันประกาศเป็น structure (ในรูปแบบของภาษา c )

    struct CGPoint {
    CGFloat x;
    CGFloat y;
    };
    typedef struct CGPoint CGPoint;

    และเนื่องจากว่า CGPoint เป็นเพียงแค่ structure ไม่ได้เป็น class
    ที่สามารถประกาศ member data ในลักษณะของ property เหมือนอย่าง iButton
    ได้

    การเรียกใช้

    self.position // แบบนี้คือให้ self เรียก property ที่ชื่อว่า position
    อันนี้ถูก แต่
    self.position.x // แบบนี้คือให้ position เรียก property ที่ชื่อว่า x
    ซึ่งมันไม่มีจึงผิด


    วิธีการแก้ไข ( มีหลายแบบมาก แต่ผมจะแนะนำวิธีง่ายสุดให้ก่อน )

    ผมเข้าใจว่าน้องเค้าคงต้องการ จะเก็บค่า position ไว้ใน class ของ iButton
    ดังนั้นแล้ว เราเพียงแค่ประกาศ position ไม่ต้องเป็น pointer
    ก็จบแล้วครับ เพราะ position ไม่ได้เป็น class เป็นเพียงแค่ structure
    ภาษา c เท่านั้นเอง

    code ที่แก้ไขก็จะเป็น แบบนี้ครับ

    // .h

    @interface iButton : NSObject
    {
    CGPoint position;
    }


    การเรียกใช้ ก็เปลี่ยนจาก

    self.position.x ให้เป็น position.x แทน

  7. #7


    ขอบคุณมากๆ ครับๆๆๆ

    ยังไงถ้ามีปัญหาจะมาถามใหม่ครับ

  8. #8


    ขอบคุณมากๆ ครับๆๆๆ

    ยังไงถ้ามีปัญหาจะมาถามใหม่ครับ

  9. #9
    Junior Member
    Join Date
    Dec 2009
    Posts
    2


    เขียนแล้วลองเล่นบนเครื่องจริงๆได้ป่าวครับ ? พอดีสนใจการเขียน Objective C เกี่ยวกับเกมส์บน iphone และ Application บน ipone มากครับ ขอบคำชี้แนะด้วยครับ

  10. #10
    Junior Member
    Join Date
    Dec 2009
    Posts
    2


    เขียนแล้วลองเล่นบนเครื่องจริงๆได้ป่าวครับ ? พอดีสนใจการเขียน Objective C เกี่ยวกับเกมส์บน iphone และ Application บน ipone มากครับ ขอบคำชี้แนะด้วยครับ

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 2
    Last Post: 02-07-2009, 01:44 PM
  2. มีปัญหาเกี่ยวกับ IE คับ
    By 10percent_boy in forum Newbie / Starter Hacker
    Replies: 2
    Last Post: 28-09-2007, 03:32 PM
  3. มีปัญหาเกี่ยวกับ BIOS
    By NY lovely in forum IT problem consult
    Replies: 2
    Last Post: 29-08-2007, 11:15 AM
  4. Replies: 1
    Last Post: 23-08-2007, 07:12 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •