16
iPhone Application Development Course NSURLConnection (Case study) Mr.Chalermchon Sommana Brightest IDEA Date: 9 May 2011

iPhone NSURLConnection-2

Embed Size (px)

DESCRIPTION

iphone nsurlconnection webservice with case study XPLog's web service see more android/iOS application Development : http://adayd3sign.wordpress.com/ join me : http://www.brightest-idea.com

Citation preview

Page 1: iPhone NSURLConnection-2

iPhone Application Development Course

NSURLConnection(Case study)

Mr.Chalermchon SommanaBrightest IDEADate: 9 May 2011

Page 2: iPhone NSURLConnection-2

Outline

●Connect URL●Receive Data from URL change to XML Parser●Read XML Parser●Create Class for XML●Present XML Data

Page 3: iPhone NSURLConnection-2

Overview

MySQL

PHP

iPhone

Connect URL

XML

Query database

Page 4: iPhone NSURLConnection-2

Connect URL

●Case Study web service URL● http://203.185.96.228/sarakham2011/xplog/showFollowLike.php● http://203.185.96.228/sarakham2011/xplog/checkLogin.php

●Create NSURL with string●URLRequest●Connection and set delegate

Page 5: iPhone NSURLConnection-2

NSURLConnection delegate

●Start connectiondidReceiveResponse

●Receive data from URLdidReceiveData

●End connectionconnectionDidFinishLoading

●Error reportdidFailWithError

Page 6: iPhone NSURLConnection-2

XMLParser delegate

●Start DocumentparserDidStartDocument

●Start ElementdidStartElement

●CharacterfoundCharacters

●End ElementdidEndElement

●End DocumentparserDidEndDocument

Page 7: iPhone NSURLConnection-2

XML Structure

http://203.185.96.228/sarakham2011/xplog/showFollowLike.php

<ShowTopi cFol l owLi ke> <t opi c>

<t _i d>14238</ t _i d> <t _t i t l e>ตรอกบ้านจีน</ t _t i t l e> <s t ar >45</ s t ar > <s our ce>0111110952426710112. j pg</ s our ce> <des c>กดดูรายละเอียด</ des c>

</ t opi c> …

</ ShowTopi cFol l owLi ke>

Page 8: iPhone NSURLConnection-2

Custom Class: Topic

Topic Class:{NSInteger tid,star;NSString *tTitle,*tSource,*tDesc;

}

Page 9: iPhone NSURLConnection-2

Workshop

Page 10: iPhone NSURLConnection-2

iPhone Application Development Course

NSURLConnectionContact usBrightest IDEA: http://www.brightest-idea.com

Mr.Chalermchon SommanaBlog: http://adayd3sign.wordpress.comThank you.

Page 11: iPhone NSURLConnection-2

Connection Source code

Page 12: iPhone NSURLConnection-2

Connection Source code (2)

Page 13: iPhone NSURLConnection-2

XMLParser Source code

Page 14: iPhone NSURLConnection-2

XMLParser Source code (2)

Page 15: iPhone NSURLConnection-2

XMLParser Source code (3)

Page 16: iPhone NSURLConnection-2

Topic Class Source code