加载时表视图不起作用。它发出错误。这是错误。
NSRangeException',原因:' * - [__ NSArrayM objectAtIndex:]:索引1 超出界限[0 .. 0]'
这是我的代码。
- (void)viewDidLoad
{
[super viewDidLoad];
uiButtonArray =[[NSMutableArray alloc]init];
[SharedPreferenceUtil saveBoolValueInUserDefaults:YES forKey:@"viewupdate"];
indexval = 0;
if (isNotification)
{
isNotification = NO;
[UIApplication sharedApplication].applicationIconBadgeNumber=0;
//[[UIApplication sharedApplication]cancelAllLocalNotifications];
}
[self getRemarks];
[self updateUI];
// Do any additional setup after loading the view.
}
-(void) viewDidLayoutSubviews
{
[remarksTable setFrame:CGRectMake(5, 190, [[UIScreen mainScreen]bounds].size.width-20, [[UIScreen mainScreen]bounds].size.height-180)];
[Calendarscroll setFrame:CGRectMake(0,90,320, 59)];
[Calendarscroll setBackgroundColor:[UIColor whiteColor]];
Calendarscroll.contentSize =CGSizeMake(1500, 59);
[self.view layoutIfNeeded];
}
-(void)fillcalendar
{
buttonIndex=0;
for (UIButton *btn in uiButtonArray )
{
[btn removeFromSuperview];
}
[uiButtonArray removeAllObjects];
globalDate=currentDate;
// this is the placeholder for the calendar
// setting up the month title
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMMM yyyy"];
[monthLabel setText:[df stringFromDate:currentDate]];
NSDateComponents *components = [calendar components:NHWunits fromDate:currentDate];
// change for the first day
[components setDay:1];
// update the component
components = [calendar components:NHWunits fromDate:[calendar dateFromComponents:components]];
[components setDay:-[components weekday]+2];
int lessDay = [components day];
int month = [components month];
int year = [components year];
// extracting components from date
NSDateComponents *components3 = [calendar components:NHWunits fromDate:[NSDate date]];
int currentDateInteger=[components3 day];
monthInteger=[components3 month];
yearInteger=[components3 year];
CGFloat orgx=0,orgy=1.0f;
int m=month;
for (int week=0; week<6 && month==m; week++)
{
for (int d=0; d<7; d++)
{
[components setDay:lessDay];
int d =[[calendar components:NHWunits fromDate:[calendar dateFromComponents:components]] day];
m =[[calendar components:NHWunits fromDate:[calendar dateFromComponents:components]] month];
int y =[[calendar components:NHWunits fromDate:[calendar dateFromComponents:components]] year];
NSString *daysdate = [NSString stringWithFormat:@"%d-%d-%d",d,m,y];
NSDateFormatter *nwd =[[NSDateFormatter alloc]init];
[nwd setDateFormat:@"dd-MM-yyyy"];
NSDate *notdays =[nwd dateFromString:daysdate];
[nwd setDateFormat:@"EEE"];
NSString *WDays =[nwd stringFromDate:notdays];
UILabel *Weekdays =[self createLbl:WDays orgx:orgx orgy:orgy];
UIButton *button = [self createBtn:d orgx:orgx orgy:orgy Date:currentDate];
if (d==defaultDateInteger && defaultMonthInteger==m)
{
// globalButton=button;
}
NSString *isSunday =[NSString stringWithFormat:@"%d-%d-%d",d,m,y];
NSDate *date = [NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"d-M-yyyy"];
NSString *cdate = [df stringFromDate:date];
NSLog(@"CURRENT DATE: %@ \n %@", isSunday,cdate);
//Circle the Today's Date
if ([isSunday isEqualToString:cdate]) {
[button setBackgroundColor:[UIColor lightGrayColor]];
// [button.titleLabel setTextColor:[UIColor whiteColor]];
}
[Calendarscroll addSubview:button];
[Calendarscroll addSubview:Weekdays];
button.tag=buttonIndex;
[uiButtonArray addObject:button];
// [DayArray addObject:Weekdays];
buttonIndex++;
orgx+=46;
lessDay++;
}
}
}
- (UIButton*) createBtn:(int)day orgx:(CGFloat)orgx orgy:(CGFloat)orgy Date:(NSDate*)caldate
{
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
NSDateFormatter *cMonth = [[NSDateFormatter alloc] init];
[cMonth setDateFormat:@"MMMM yyyy"];
NSDate *date = [NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"dd-MM-yyyy"];
NSDateFormatter *dff = [[NSDateFormatter alloc]init];
[dff setDateFormat:@"d"];
NSDateFormatter *days =[[NSDateFormatter alloc]init];
[days setDateFormat:@"EEE"];
NSString *cdate1 = [dff stringFromDate:date];
NSLog(@"The single date is: %@",cdate1);
NSString *cdate = [df stringFromDate:date];
NSLog(@"df is: %@",cdate);
NSString *cdays =[days stringFromDate:date];
NSLog(@"The days are: %@",cdays);
[button setBackgroundColor:[UIColor colorWithRed:0.52 green:0.5 blue:0.12 alpha:0.8]];
button.titleEdgeInsets = UIEdgeInsetsMake(-14.0, -16.0, 0.0, 0.0);
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitle:[NSString stringWithFormat:@"%d", day] forState:UIControlStateNormal];
[button.titleLabel setFont:[UIFont systemFontOfSize:16.0f]];
button.frame=CGRectMake(orgx, 28, 35, 30);
return button;
}
-(UILabel*) createLbl:(NSString*)Days orgx:(CGFloat)orgx orgy:(CGFloat)orgy
{
UILabel *Weekdays =[[UILabel alloc]initWithFrame:CGRectMake(orgx, 5, 35, 20)];
NSDateFormatter *cMonth = [[NSDateFormatter alloc] init];
[cMonth setDateFormat:@"MMMM yyyy"];
NSDate *Ndate = [NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"dd-MM-yyyy"];
NSDateFormatter *days =[[NSDateFormatter alloc]init];
[days setDateFormat:@"EEE"];
NSString *cdate = [df stringFromDate:Ndate];
NSLog(@"df is: %@",cdate);
NSString *cdays =[days stringFromDate:Ndate];
NSLog(@"The days are: %@",cdays);
[Weekdays setBackgroundColor:[UIColor colorWithRed:0.52 green:0.5 blue:0.12 alpha:0.8]];
//Weekdays.titleEdgeInsets = UIEdgeInsetsMake(-14.0, -16.0, 0.0, 0.0);
[Weekdays setTextColor:[UIColor blackColor]];
[Weekdays setText:[NSString stringWithFormat:@"%@", Days]];
[Weekdays setFont:[UIFont systemFontOfSize:16.0f]];
return Weekdays;
}
-(void)CreateSection
{
sectionsData =[[NSMutableArray alloc]init];
for (int i=0; i<collectHW.count; i++)
{
/* [sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
// [Sectiondata addObject:sectionarray];
NSLog(@"The description is: %@",sectionsData);*/
//for (int i =0; i<newsArray.count; i++)
if ([[[collectHW objectAtIndex:i] valueForKey:@"path"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
}
else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]], nil]];
}
/* if ([[[collectHW objectAtIndex:i] valueForKey:@"path"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"name"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
}
}else{////deadlinedate........
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
}
}
}else
{//////name........
if ([[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
}
}else{////deadlinedate........
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Tap to download attachment."],@"hasAttachment",nil]];
}
}
}
}else
{/////////path......
if ([[[collectHW objectAtIndex:i] valueForKey:@"name"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],nil]];
// NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],nil]];
}
}else{////deadlinedate........
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],nil]];
// NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"Title: %@",[[collectHW objectAtIndex:i] valueForKey:@"name"]],nil]];
}
}
}else
{//////name........
if ([[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],nil]];
// NSLog(@"The description is: %@",sectionsData);
}else
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DUE DATE: %@",[[collectHW objectAtIndex:i] valueForKey:@"deadlinedate"]],nil]];
}
}else{////deadlinedate........
if ([[[collectHW objectAtIndex:i] valueForKey:@"description"]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:BLANK_STRING]].length!=0)
{
[sectionsData addObject:[[NSMutableArray alloc] initWithObjects:[NSString stringWithFormat:@"DESCRIPTION: %@",[[collectHW objectAtIndex:i] valueForKey:@"description"]],nil]];
// NSLog(@"The description is: %@",sectionsData);
}else
{
[self showDropDownViewWithmessage:@"No homework is yet to display." title:@"Message" inView:self.view];
}
}
}
}*/
NSLog(@"The new data is: %@",sectionsData);
}
UIColor *sectionsColor = [UIColor colorWithRed:36.0f/255.0f green:158.0f/255.0f blue:110.0f/255.0f alpha:1.0f];
UIColor *sectionTitleColor = [UIColor whiteColor];
UIFont *sectionTitleFont = [UIFont fontWithName:@"Futura" size:24.0f];
EMAccordionSection *section;
// emTV.closedSectionIcon=[UIImage imageNamed:@"icon_down.png"];
// emTV.openedSectionIcon=[UIImage imageNamed:@"icon_up.png"];
for (int i = 0 ; i<collectHW.count; i++)
{
section = [[EMAccordionSection alloc] init];
[section setBackgroundColor:sectionsColor];
[section setItems:[sectionsData objectAtIndex:i]];
[section setTitle:[NSString stringWithFormat:@"%@(%@)",[[collectHW objectAtIndex:i] valueForKey:@"subjectname"],[[collectHW objectAtIndex:i] valueForKey:@"assignmenttype"]]];
[section setTitleFont:sectionTitleFont];
[section setTitleColor:sectionTitleColor];
[emTV addAccordionSection:section];
}
NSLog(@"The Section is: %@",section.title);
[remarksTable reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"emCell"];
NSMutableArray *items = [sectionsData objectAtIndex:indexPath.section];
UILabel *titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(5.0f,0.0f,220.0f, 40.0f)];
[titleLbl setFont:[UIFont boldSystemFontOfSize:14.0f]];
[titleLbl setText:[items objectAtIndex:indexPath.row]];
[titleLbl setBackgroundColor:[UIColor clearColor]];
[titleLbl setTextColor:[UIColor blackColor]];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [[items objectAtIndex:indexPath.row] sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height+10, 40.0f);
[titleLbl setFrame:CGRectMake(30, titleLbl.frame.origin.y, 280.0f, height)];
titleLbl.numberOfLines=30;
[[cell contentView] addSubview:titleLbl];
[cell setBackgroundColor:[UIColor clearColor]];
return cell;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//TAHomeworksTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"homeworkCell"];
NSMutableArray *items = [sectionsData objectAtIndex:indexPath.section];
NSString *text = [items objectAtIndex:[indexPath row]];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height+15, 40.0f);
return height;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
NSString *text = [NSString stringWithFormat:@"%@(%@)",[[collectHW objectAtIndex:section] valueForKey:@"subjectname"],[[collectHW objectAtIndex:section] valueForKey:@"assignmenttype"]];
NSLog(@"The text is: %@",text);
CGSize constraint = CGSizeMake(250.0f - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont boldSystemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height+35, 40.0f);
return height;
}
- (UIColor *)colorWithHexString:(NSString *)str_HEX alpha:(CGFloat)alpha_range{
int red = 0;
int green = 0;
int blue = 0;
sscanf([str_HEX UTF8String], "#%02X%02X%02X", &red, &green, &blue);
return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha_range];
}
-(void)updateUI
{
emTV = [[EMAccordionTableViewController alloc] initWithTable:remarksTable];
[emTV setDelegate:self];
[self addCustomBackButtonWithNaviBarColor:[self colorWithHexString:@"#c3b395" alpha:1.0f]];
//[self addCustomBackButton];
if (IS_IOS7)
{
[remarksTable setSeparatorInset:UIEdgeInsetsZero];
}
[self addCustomBackButtonWithNaviBarColor:[self colorWithHexString:@"#006666" alpha:1.0f]];
NSMutableArray *menuindex = (NSMutableArray *)[SharedPreferenceUtil getNSObject:@"menuindexarray"];
[self addCutomTitleToCustomNavigationBar:[NSString stringWithFormat:@"%@",[(NSMutableArray *)[SharedPreferenceUtil getNSObject:@"appnamearray"]objectAtIndex:[[menuindex objectAtIndex:[(NSString *)[SharedPreferenceUtil getNSObject:@"selmenuitem"]integerValue]]integerValue]]]];
currentDate=[NSDate date];
globalDate=currentDate;
calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
//today = [[NSDate alloc] initWithTimeIntervalSinceNow:1];
NSDateComponents *components = [calendar components:NHWunits fromDate:currentDate];
defaultDateInteger=components.day;
[self fillcalendar];
// [self getdate];
// [self dateSelectedInPickerView];
[self getRemarks];
}
-(void)getRemarks
{
if ([self connected])
{
[self showLoadingViewWithMessage:@"Loading..."];
[[DPSAppService sharedInstance] getDataFromURL:[self getURL] responseBlock:^(NSDictionary *response)
{
if (response)
{
NSLog(@"%@",response);
homewokArray = [response valueForKey:@"studentassignment"];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd-MM-yyyy"];
NSDate *CurrentDate =[NSDate date];
NSString *cDate =[df stringFromDate:CurrentDate];
NSLog(@" current Month date is: %@",cDate);
collectHW =[[NSMutableArray alloc]init];
for (int i=0; i<homewokArray.count; i++)
{
NSLog(@"New data is: %@",[[homewokArray objectAtIndex:i]valueForKey:@"date"]);
if ([cDate isEqualToString:[[homewokArray objectAtIndex:i]valueForKey:@"date"]])
{
[collectHW addObject:[homewokArray objectAtIndex:i]];
}
else
{
NSLog(@"No Homework today");
}
}
NSLog(@"Current data of homework is: %@",collectHW);
if (homewokArray.count==0)
{
[self showDropDownViewWithmessage:@"No homework is yet to display." title:@"Message" inView:self.view];
}else
{
[self CreateSection];
// [self showHomework];
}
}
else
{
[self showDropDownViewWithmessage:SERVER_ERROR title:ERROR inView:self.view];
}
[self hideLoadingViewWithSuccessMessage:LOGIN_SUCCESS];
[self addBottomView];
}];
}
else
{
}
}
-(NSString *)getURL
{
return [NSString stringWithFormat:@"%@%@%@classid=%@&academciyearid=%@§ionid=%@",[SharedPreferenceUtil getNSObject:@"baseerpurl"],URL,STUDENT_HOMEWORK,[[SharedPreferenceUtil getNSObject:STUDENT_DATA_JSON ]valueForKey:@"classid"],[[SharedPreferenceUtil getNSObject:STUDENT_DATA_JSON ]valueForKey:@"academciyearid"],[[SharedPreferenceUtil getNSObject:STUDENT_DATA_JSON ]valueForKey:@"sectionid"]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
答案 0 :(得分:0)
添加异常断点并查看Array中有多少个对象以及从该数组中取出对象的索引,通过这样做,您将能够找出并解决问题:)
答案 1 :(得分:0)
您始终必须在numberOfRowsInSection方法中返回正确的值。通常,该值是数组的计数。如果这也是你的情况,那么请调试你的流程并检查是否存在不一致。每当更改或更改数组的计数时,都应重新加载tableview。