views:

236

answers:

1

Hi

Sorry if i did wrong english typing

I want to show a text in UITextView depend on the date, some thing like "in This Day App", I have this code in action

-(void)changingText:(id)sender{

 NSDateFormatter *df = [[NSDateFormatter alloc] init];

 df.dateStyle = NSDateFormatterMediumStyle;

 label.text = [NSString stringWithFormat:@"%@", [df stringFromDate:datePicker.date]];
 NSDictionary *pageData = [[DataSource sharedDataSource] dataForPage:pageIndex];

 NSString *dateText = [pageData objectForKey:@"pageName"];

 NSString *dateInfo = [df stringFromDate:datePicker.date];

 if ([dateText isEqualToString: dateInfo]) {

  myText.text = [pageData objectForKey:@"pageText"];
 }

 [df release];
}

My qustion is how to update UITextView With the data from NSDictionery ForKey@"pageText" , because it shows just the first object.

here is the Object that i want to triger when the date been selected.

    - (id)init
{
    self = [super init];
    if (self != nil)
    {
     dataPages = [[NSArray alloc] initWithObjects:

         [NSDictionary dictionaryWithObjectsAndKeys:
          @"Oct 3, 2009", @"pageName",
          @"First Object", @"pageText",
          nil],

         [NSDictionary dictionaryWithObjectsAndKeys:
          @"Oct 10, 2009", @"pageName",
          @"second Object", @"pageText",
          nil],

         [NSDictionary dictionaryWithObjectsAndKeys:
          @"Oct 27, 2009", @"pageName",
          @"Third Object", @"pageText",
          nil],



         nil];


    }
    return self;
}
A: 

I'm not sure if I understand your question, but I think you need to make the object from your dictionary into an NSString like this:

-(void)changingText:(id)sender{
    NSDateFormatter *df = [[NSDateFormatter alloc] init];

    df.dateStyle = NSDateFormatterMediumStyle;

    NSDictionary *pageData = [[DataSource sharedDataSource] dataForPage:pageIndex];
    NSString *dateText = (NSString *)[pageData objectForKey:@"pageName"];
    NSString *dateInfo = [df stringFromDate:datePicker.date];

    label.text = [NSString stringWithFormat:@"%@", [df stringFromDate:dateInfo]];
    if ([dateText isEqualToString: dateInfo]) {
     myText.text = dateText;
    }

    [df release];
}
Justin Gallagher
Thanks man , but the dame probel, it just triger the first Object, I added the Code to my qustion above,
Ibrahim
What do you want the string in the text field to be? "First Object, Second Object, Third Object"?
Justin Gallagher
Also, where is pageIndex being set?
Justin Gallagher