Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-12-2010, 06:04 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 83
Default structs

I need to use a custom struct, I am trying to parse some XML with NSXMLParser, and my idea is to have a struct like so:

Code:
typedef struct {
	NSString *tag;
	NSMutableString *value;
} currentXMLElem;

// this is placed outside the implementation
And I'd initiate one when I get to a desired tag in the XML, and when I come across and characters I'd progressively add them to the value property.

When I get to EndElement, I'd check if there's a "currentCMLElem" variable initiated, if so, clear it

Loop like this until the end of the XML.

But I can't seem to use my struct, here is a sample:

Code:
// in didStartElement delegate method:

typedef currentXMLElem currentElem;
currentElem.tag  = @"someTag";
And right there I get the following error:

error: expected identifier or '(' before '.' token

I don't understand what I need, my tag is a property of the struct, and Xcode even autocompletes with the property name "tag".

What could the error be ?


Hope you can help, thanks
djp_phillips is offline   Reply With Quote
Old 02-12-2010, 06:19 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 791
Default

A typedef just means an "alias" for your struct name, you need a currentXMLElem variable, declare it like any other type.
Code:
currentXMLElem currentElem;
nobre84 is offline   Reply With Quote
Reply

Bookmarks

Tags
delegate methods, iphone, parse, struct, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 274
20 members and 254 guests
ADY, apatsufas, ckgni, dacapo, Dani77, Fritzer, ghost, HDshot, headkaze, jakerocheleau, joeallenpro, masc2279, mer10, MozyMac, mystic.purple, objch, Rudy, themathminister, timle8n1, Zool
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,878
Threads: 89,223
Posts: 380,731
Top Poster: BrianSlick (7,129)
Welcome to our newest member, olga2000
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:37 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0