PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my alerts
my settings
my profile
Don't like ads?
PRO users
don't see any ads ;-)
Public Pastes
Untitled
4 sec ago
test
Lua | 14 sec ago
Untitled
17 sec ago
Untitled
21 sec ago
Untitled
HTML | 22 sec ago
Untitled
23 sec ago
Untitled
29 sec ago
axl gay
42 sec ago
New Paste
Rows not being inserted into UITable -(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionOpened:(NSInteger)section { if (![[sectionHeaderArray objectAtIndex:section] isOpen]) { [[sectionHeaderArray objectAtIndex:section] setIsOpen:YES]; NSLog(@"self.tableView: %@", self.tableView); id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section]; NSInteger countOfRowsToInsert = [sectionInfo numberOfObjects]; NSMutableArray *indexPathsToInsert = [[NSMutableArray alloc] init]; for (NSInteger i = 0; i < countOfRowsToInsert; i++) { [indexPathsToInsert addObject:[NSIndexPath indexPathForRow:i inSection:section]]; } // Apply the updates. [self.tableView beginUpdates]; NSLog(@"Count of rows to insert: %d", [indexPathsToInsert count]); NSLog(@"Rows before insert: %d", [self.tableView numberOfRowsInSection:section]); [self.tableView insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:UITableViewRowAnimationTop]; NSLog(@"Rows after insert: %d", [self.tableView numberOfRowsInSection:section]); [self.tableView endUpdates]; } } -(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionClosed:(NSInteger)section { if ([[sectionHeaderArray objectAtIndex:section] isOpen]) { [[sectionHeaderArray objectAtIndex:section] setIsOpen:NO]; NSInteger countOfRowsToDelete = [self.tableView numberOfRowsInSection:section]; if (countOfRowsToDelete > 0) { NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init]; for (NSInteger i = 0; i < countOfRowsToDelete; i++) { [indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:section]]; } [self.tableView beginUpdates]; NSLog(@"Count of rows to delete: %d", [indexPathsToDelete count]); NSLog(@"Rows before delete: %d", [self.tableView numberOfRowsInSection:section]); [self.tableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:UITableViewRowAnimationTop]; NSLog(@"Rows after delete: %d", [self.tableView numberOfRowsInSection:section]); } [self.tableView endUpdates]; } } 2012-03-31 13:36:17.454 QuickList7[5523:fb03] Count of rows to insert: 3 2012-03-31 13:36:17.454 QuickList7[5523:fb03] Rows before insert: 0 2012-03-31 13:36:17.454 QuickList7[5523:fb03] Rows after insert: 0 2012-03-31 13:48:35.783 QuickList7[5523:fb03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid table view update. The application has requested an update to the table view that is inconsistent with the state provided by the data source.' - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // number of menus, plus 1 if a menu is open, plus 1 static cell return [self.restaurant.menus count]+(self.menu != nil ? 1 : 0)+1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // if this section is our selected menu, return number of items, otherwise return 1 int numberOfRowsInSection = ([self indexPathIsInMenuItemSection:section] ? [[self.menu items] count] : 1); return numberOfRowsInSection; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == [tableView numberOfSections]-1) { // ... set up and return static cell } if ([self indexPathIsInMenuItemSection:indexPath.section]) { // ... set up and return menu item cell } else { // ... set up and return menu name cell } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; // return if it's a static cell if (indexPath.section==[tableView numberOfSections]-1) return; // if it's a menu name cell, close open menu and maybe expand this menu if (![self indexPathIsInMenuItemSection:indexPath.section]) { BOOL reset = self.menu == m; if (reset) [self reloadTableView:self.tableView withMenu:nil animated:YES autoscroll:NO]; else [self reloadTableView:self.tableView withMenu:m animated:YES autoscroll:YES]; } } - (BOOL)indexPathIsInMenuItemSection:(NSInteger)section { // returns YES if section refers to our MenuItemCells int indexOfMenu = [self.restaurant getIndexOfMenu:self.menu]; return indexOfMenu != -1 && section == indexOfMenu+1; } - (void)reloadTableView:(UITableView *)tableView withMenu:(Menu *)menu animated:(BOOL)animated autoscroll:(BOOL)autoscroll { int oldIndex = [self.restaurant getIndexOfMenu:self.menu]; int newIndex = [self.restaurant getIndexOfMenu:menu]; [tableView beginUpdates]; if (oldIndex != -1) { // index of [section for items] is oldIndex+1 [tableView deleteSections:[NSIndexSet indexSetWithIndex:oldIndex+1] withRowAnimation:UITableViewRowAnimationTop]; } if (newIndex != -1) { // index for [section for items] is newIndex+1 [tableView insertSections:[NSIndexSet indexSetWithIndex:newIndex+1] withRowAnimation:UITableViewRowAnimationTop]; [self setMenu:menu]; } else { // no new menu [self setMenu:nil]; } [tableView endUpdates]; if (autoscroll) [self autoscroll]; } - (void)autoscroll { if (self.menu != nil) { int section = [self.restaurant getIndexOfMenu:self.menu]; if (section != -1) { NSUInteger indexes[] = {section,0}; NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexes length:2]; [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; } } } [self reloadTableView:self.tableView withMenu:self.menu animated:YES autoscroll:YES]; - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { UITableView *tv = self.tView; switch(type) { case NSFetchedResultsChangeInsert: if ([[sectionHeaderArray objectAtIndex:newIndexPath.section] isOpen]) { [tv insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; } break; case NSFetchedResultsChangeDelete: if ([[sectionHeaderArray objectAtIndex:indexPath.section] isOpen]) { [tv deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } break; case NSFetchedResultsChangeUpdate: if ([[sectionHeaderArray objectAtIndex:indexPath.section] isOpen]) { [self configureCell:[tv cellForRowAtIndexPath:indexPath] atIndexPath:indexPath]; } break; case NSFetchedResultsChangeMove: if ([[sectionHeaderArray objectAtIndex:indexPath.section] isOpen]) { [tv deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } if ([[sectionHeaderArray objectAtIndex:newIndexPath.section] isOpen]) { [tv insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]withRowAnimation:UITableViewRowAnimationFade]; } break; } }
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
HTML 5
Java
JavaScript
Lua
None
Objective C
Perl
PHP
Python
Rails
-------------
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
ActionScript
ActionScript 3
Ada
ALGOL 68
Apache Log
AppleScript
APT Sources
ARM
ASM (NASM)
ASP
Asymptote
autoconf
Autohotkey
AutoIt
Avisynth
Awk
BASCOM AVR
Bash
Basic4GL
BibTeX
Blitz Basic
BNF
BOO
BrainFuck
C
C for Macs
C Intermediate Language
C#
C++
C++ (with QT extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
ChaiScript
Clojure
Clone C
Clone C++
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
DCL
DCPU-16
DCS
Delphi
Delphi Prism (Oxygene)
Diff
DIV
DOS
DOT
E
ECMAScript
Eiffel
Email
EPC
Erlang
F#
Falcon
FO Language
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
Game Maker
GDB
Genero
Genie
GetText
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9 Plus
HTML
HTML 5
Icon
IDL
INI file
Inno Script
INTERCAL
IO
J
Java
Java 5
JavaScript
jQuery
KiXtart
Latex
LDIF
Liberty BASIC
Linden Scripting
Lisp
LLVM
Loco Basic
Logtalk
LOL Code
Lotus Formulas
Lotus Script
LScript
Lua
M68000 Assembler
MagikSF
Make
MapBasic
MatLab
mIRC
MIX Assembler
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MPASM
MXML
MySQL
Nagios
newLISP
None
NullSoft Installer
Oberon 2
Objeck Programming Langua
Objective C
OCalm Brief
OCaml
Octave
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
ParaSail
PARI/GP
Pascal
PAWN
PCRE
Per
Perl
Perl 6
PHP
PHP Brief
Pic 16
Pike
Pixel Bender
PL/SQL
PostgreSQL
POV-Ray
Power Shell
PowerBuilder
ProFTPd
Progress
Prolog
Properties
ProvideX
PureBasic
PyCon
Python
Python for S60
q/kdb+
QBasic
R
Rails
REBOL
REG
Rexx
Robots
RPM Spec
Ruby
Ruby Gnuplot
SAS
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term
thinBasic
TypoScript
Unicon
UnrealScript
UPC
Urbi
Vala
VB.NET
Vedit
VeriLog
VHDL
VIM
Visual Pro Log
VisualBasic
VisualFoxPro
WhiteSpace
WHOIS
Winbatch
XBasic
XML
Xorg Config
XPP
YAML
Z80 Assembler
ZXBasic
Paste Expiration:
Never
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
Paste Exposure:
Public
Unlisted
Private (members only)
Paste Name / Title:
Hello
Guest
Sign Up
or
Login
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login