Showing posts with label ObjectiveC categories. Show all posts
Showing posts with label ObjectiveC categories. Show all posts

Objective C: UITableView: Detect which section header on top

static NSInteger currentTopVisibleSection = -1;

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    NSIndexPath *topCellPath = [[tableView indexPathsForVisibleRows] objectAtIndex:0];
    if (currentTopVisibleSection != topCellPath.section) {
        currentTopVisibleSection = topCellPath.section;
        NSLog(@"current section on top is %d", currentTopVisibleSection);
    }

    NSString *header = [NSString stringWithFormat:@"Section %d", section];
    return header;
}

Xcode: include ObjectiveC categories int static library

If you need to include ObjectiveC categories or other framework using ObjectiveC categories ( for example JSON framework ) into your own static library you probably get


-[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance


In your project that using your static library you need to set in Project Settings for "Other Linker Flags" property two additional flags:

-ObjC
-all_load