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 08-04-2009, 12:29 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default Email Contents of An Array.

I have an email setup and it accepts html but I cant find how to fill me email with the contents of an array! I was thinking of mayby converting the contents to an NSString so that I could put them in...

If my array has this "apple","orange","mango",nil;

How would i make it display in an email like this:
-FRUITS-
apple
orange
mango

Anybody have any luck with this?
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV
starwarsdevwookie59 is offline   Reply With Quote
Old 08-04-2009, 12:43 PM   #2 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
I have an email setup and it accepts html but I cant find how to fill me email with the contents of an array! I was thinking of mayby converting the contents to an NSString so that I could put them in...

If my array has this "apple","orange","mango",nil;

How would i make it display in an email like this:
-FRUITS-
apple
orange
mango

Anybody have any luck with this?
If your body is HTML, you can use:

Code:
NSString *s=@"-FRUITS-<br>";
s=[s stringByAppendingString:[myArray componentsJoinedByString:@"<br>"]];
Dutch is offline   Reply With Quote
Old 08-04-2009, 03:11 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

Quote:
Originally Posted by Dutch View Post
If your body is HTML, you can use:

Code:
NSString *s=@"-FRUITS-<br>";
s=[s stringByAppendingString:[myArray componentsJoinedByString:@"<br>"]];
Sweet Thanks! That worked great! I've been implementing it into my App but I've run into another issue. What if I have another string and need it displayed after the fruits but before the break. Like:
Mango 7
Apple 3
Orange 8

How would you accomplish that?
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV
starwarsdevwookie59 is offline   Reply With Quote
Old 08-04-2009, 03:38 PM   #4 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
Sweet Thanks! That worked great! I've been implementing it into my App but I've run into another issue. What if I have another string and need it displayed after the fruits but before the break. Like:
Mango 7
Apple 3
Orange 8

How would you accomplish that?
I would make my array something like
@"Mango 7",
@"Apple 3",
@"Orange 8"

You may need to change the way your Array is constructed, or put together a separate array of the "finished product" items. I always like to work with a finished product.
Dutch is offline   Reply With Quote
Old 08-04-2009, 03:44 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

Quote:
Originally Posted by Dutch View Post
I would make my array something like
@"Mango 7",
@"Apple 3",
@"Orange 8"

You may need to change the way your Array is constructed, or put together a separate array of the "finished product" items. I always like to work with a finished product.
I cant do that... the arrays cant be combined into one... they are both very separate. I have two arrays:
"Apple","Orange","Mango",nil;
"7","3","5",nil;

I need them to show
Apple 7
Orange 3
Mango 5

All i can get though is this:
Apple
Orange
Mango
7
3
5

Theres gotta be some html or c solution to this...
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV
starwarsdevwookie59 is offline   Reply With Quote
Old 08-04-2009, 03:57 PM   #6 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Make a third Array...

Code:
NSMutableArray *thirdArray=[[NSMutableArray alloc] init];

for (NSInteger i=0; i<[firstArray count]; i++){
    NSString *str=[NSString stringWithFormat:@"%@ %@",
                                            [firstArray objectAtIndex:i],
                                            [secondArray  objectAtIndex:i]
                        ];
    [thirdArray addObject:str];
}

NSString *s=@"-FRUITS-<br>";
s=[s stringByAppendingString:[thirdArray componentsJoinedByString:@"<br>"]];
[thirdArray release];
This code assumes firstArray and secondArray have the same number of items in them.

Last edited by Dutch; 08-04-2009 at 03:59 PM.
Dutch is offline   Reply With Quote
Old 08-04-2009, 11:16 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

Worked beautifully thanks so much!
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV
starwarsdevwookie59 is offline   Reply With Quote
Reply

Bookmarks

Tags
array, email, nsstring

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: 254
19 members and 235 guests
ADY, Alsahir, beleg_1998, Dani77, e2applets, iDifferent, iph_s, JamesCahall, JasonR, mer10, Monstertaco, prchn4christ, Promo Dispenser, Robiwan, Rudy, smithdale87, spiderguy84, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,756
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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