Works for me. Not saying it doesn't work for you, but the problem isn't the 
code.

Created a fresh Single View Application iOS project.
Replaced ViewController.m source with the code below.
Added a UITableView to the View Controller's View and hooked up the DataSource 
to the View Controller.
Ran it in the Simulator.
Scrolled the table and could see all the dwarves.

Aaron

> On Apr 28, 2015, at 9:45 AM, William Squires <wsqui...@satx.rr.com> wrote:
> 
> Thinking this was a Swift problem, I recreated the project, but with ObjC as 
> the language. I set up the UI the same as with the Swift project. It too, 
> only shows a subset of the array, only this one shows 15 rows, not 13. Here's 
> the ViewController.m
> 
> //
> //  ViewController.m
> //  SimpleObjCTable
> //
> //  Created by William Squires on 4/28/15.
> //  Copyright (c) 2015 William Squires. All rights reserved.
> //
> 
> #import "ViewController.h"
> 
> @interface ViewController ()
> 
> @property NSArray *dwarves;
> 
> @end
> 
> @implementation ViewController
> 
> - (void)viewDidLoad
> {
> [super viewDidLoad];
> self.dwarves = [NSArray arrayWithObjects:@"Sleepy",
>                                    @"Sneezy",
>                                    @"Bashful",
>                                    @"Happy",
>                                    @"Doc",
>                                    @"Grumpy",
>                                    @"Dopey",
>                                    @"Thorin",
>                                    @"Dorin",
>                                    @"Nori",
>                                    @"Ori",
>                                    @"Balin",
>                                    @"Dwalin",
>                                    @"Fili",
>                                    @"Kili",
>                                    @"Oin", // These are not shown.
>                                    @"Gloin",
>                                    @"Bifur",
>                                    @"Bofur",
>                                    @"Bombur",
>                                    nil];
> 
> // Do any additional setup after loading the view, typically from a nib.
> }
> 
> - (void)didReceiveMemoryWarning
> {
> [super didReceiveMemoryWarning];
> 
> // Dispose of any resources that can be recreated.
> }
> 
> #pragma mark "UITableView Methods"
> 
> -(NSInteger)tableView:(UITableView *)tableView 
> numberOfRowsInSection:(NSInteger)section
> {
> NSInteger theCount = [self.dwarves count];
> 
> NSLog(@"theCount = %ld", theCount);
> return theCount;
> }
> 
> -(UITableViewCell *)tableView:(UITableView *)tableView 
> cellForRowAtIndexPath:(NSIndexPath *)indexPath
> {
> NSLog(@"indexPath.row = %ld", indexPath.row);
> UITableViewCell *cell = [tableView 
> dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
> if (cell == nil)
>  {
>  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
> reuseIdentifier:@"SimpleTableIdentifier"];
>  }
> cell.textLabel.text = [self.dwarves objectAtIndex:indexPath.row];
> return cell;
> }
> 
> @end
> 
> running it gives me (in the debug console) 4 instances of "theCount = 20", 
> followed by 15 lines of "indexPath.row = 0" up to "indexPath.row = 14" (15 
> total, which corresponds to the comment in the initialization line for 
> dwarves = NSArray... line above.) In both cases (the Swift project, and the 
> ObjC project) I use the default view (with the size class w:any, h:any) and 
> pin the UITableView to the edges of the parent view.
>  Now I'm totally lost as to why only a limited subset of the rows are being 
> shown, especially given that tableView:numberOfRowsInSection: consistently 
> returns 20 (the number of items initializing the array). HELP!!
> 
> On Apr 26, 2015, at 11:29 AM, William Squires <wsqui...@satx.rr.com> wrote:
> 
>> I made a fairly simple iOS app (Single View template, iPhone, Swift) that 
>> has a UITableView. I've got it all hooked up, and running the project (in 
>> the simulator) shows the table view, but only 13 (out of 20) rows are ever 
>> shown.
>> 
>> here's the deal:
>> 
>> ViewController.swift
>> --------------------
>> class ViewController: UIViewController, UITableViewDelegate, 
>> UITableViewSource
>> {
>> private let dwarves = ["Sleepy",
>>                      "Sneezy",
>>                      "Bashful",
>>                      "Happy,"
>>                      "Doc",
>>                      "Grumpy",
>>                      "Dopey",
>>                      "Thorin",
>>                      "Dorin",
>>                      "Nori",
>>                      "Ori",
>>                      "Balin",
>>                      "Dwalin",
>>                      "Fili",  // From here on, these might as well not exist 
>> (index >= 13)
>>                      "Kili",
>>                      "Oin",
>>                      "Gloin",
>>                      "Bifur",
>>                      "Bofur",
>>                      "Bombur"
>>                      ]
>> let simpleTableIdentifier = "SimpleTableIdentifier"
>> 
>> ...
>> 
>> // MARK: UITableViewDataSource/UITableViewDelegate methods
>> func tableView(tableView: UITableView, numberOfRowsInSection section: Int) 
>> -> Int
>> {
>> return dwarves.count
>> }
>> 
>> func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath: 
>> NSIndexPath) -> UITableViewCell
>> {
>> var cell = 
>> tableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier) as? 
>> UITableViewCell
>> if (cell == nil)
>>   {
>>   cell = UITableViewCell(style: UITableViewCellStyle.Default, 
>> reuseIdentifier: simpleTableIdentifier)
>>   {
>> cell!.textLabel?.text = dwarves[indexPath.row]
>> return cell
>> }
>> }
>> 
>> When run, only the first 13 names are shown in the table view; everything 
>> from "Fili" on does not show up. I would expect either:
>> 
>> 1) a syntax error in the array declaration (which should be caught by Xcode)
>> 2) show all the items in the array, or
>> 3) show none of them.
>> 
>> Is there a (hidden) limit in the simulator that only 13 rows can be shown in 
>> a UITableView? If not, can anyone else replicate this problem?
>> 
>> Finally, how do I call NSLog() from Swift, and have it print an object? In 
>> ObjC, it would be:
>> 
>> NSLog(@"My object: %@\n\n",myObject);
>> 
>> where myObject resides in MyObject.m and declared in MyObject.h and 
>> implements -(NSString *)description – in Swift, I would just have a .swift 
>> file, but how would I print it (myObject variable) to the (debug) console at 
>> runtime? What about a Swift "String" type?
>> 
>> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/eeyore%40monsterworks.com
> 
> This email sent to eey...@monsterworks.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to