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

View Single Post
Old 09-09-2009, 02:33 PM   #13 (permalink)
smithdale87
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,957
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Its hard to tell you much about that error without seeing more code.

Not sure why you're getting errors trying to extend NSString. Seems odd, but I'm not at my mac right now so i cant test it out. Instead, you could do this:
Code:
typedef enum _StringType
{
     Input, Received
} StringType;
@interface MyObject: NSObject
{
    NSString* theString;
    StringType type;
    
}
@property (nonatomic, readonly) NSString* theString;
@property (readonly) StringType type;

-(id) initWithString:(NSString*) aString andType:(StringType)type;

@end

@implementation

//im sure you can figure out what goes here.
@end



//when you recieve something over wifi

MyObject* obj = [[MyObject alloc] initWithString: @"whatever was received" andType: Received ];

[myArrayOfObjects addObject: obj];
[obj release];


//when something new is input by the user
MyObject* obj = [[MyObject alloc] initWithString: @"whatever was input" andType: Input];

[myArrayOfObjects addObject: obj];
[obj release];


//in your table
-(UITableViewCell*)cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
      UITableViewCell* cell;
        //... 

       MyObject* obj = [myArrayOfObject objectAtIndex:indexPath.row];
       if( obj.type == Received )
       {
         cell.textColor = [UIColor redColor];
       }
       else if( obj.type == Input )
       {
           cell.textColor = [UIColor greenColor];
       }

        cell.text = obj.theString;
}

Last edited by smithdale87; 09-09-2009 at 02:52 PM.
smithdale87 is offline   Reply With Quote
 

» Advertisements
» Online Users: 692
22 members and 670 guests
Absentia, ADY, ayesha25, baja_yu, Bertrand21, BrianSlick, dacapo, dremayl49, Gaz, gbenna, kapps11, kosicki123, linkmx, msovani, mutantskin, nobre84, pipposanta, QuantumDoja, rivers123, SLIC, trunglee, wynonarr69
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,181
Threads: 93,920
Posts: 402,154
Top Poster: BrianSlick (7,968)
Welcome to our newest member, ayesha25
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:31 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.