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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 09-09-2010, 07:39 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 3
fishcharlie is on a distinguished road
Default Use a NSString for more than 1 class

Hello,

How do you read, write to a NSString for more than 1 class?

Charlie Fish
fishcharlie is offline   Reply With Quote
Old 09-10-2010, 11:27 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 26
jhockman is on a distinguished road
Default

Can you give an example of what you are trying to accomplish? I can't really figure out what you are asking.
jhockman is offline   Reply With Quote
Old 09-14-2010, 07:20 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 62
devanshree.c is on a distinguished road
Default

Quote:
Originally Posted by fishcharlie View Post
Hello,

How do you read, write to a NSString for more than 1 class?

Charlie Fish
this means you wanna create a global variable....?
If yes,try declaring it in appDelegate class and can retrieve it anywhere throughout the project.
devanshree.c is offline   Reply With Quote
Old 09-14-2010, 07:34 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by fishcharlie View Post
Hello,

How do you read, write to a NSString for more than 1 class?

Charlie Fish
You make one instance of one class own the NSString. Make it a property of that class. Now any other class that has a reference to the first class can reference that NSString through the property of the first class. Do not be too quick to make a variable global or pseudo global unless you have to.
RLScott is offline   Reply With Quote
Old 09-14-2010, 08:50 AM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 178
dustbyter is on a distinguished road
Default

As the others have noted, don't just make global values.


Instead you should if required use a singleton design pattern to have a single instance of an object live during the duration of your application.
dustbyter is offline   Reply With Quote
Reply

Bookmarks

Tags
class, int, iphone, read, string

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: 331
10 members and 321 guests
bignoggins, carlandrews, flamingliquid, hzwegjxg, ilmman, jenniead38, linkmx, nadav@webtview.com, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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