English 中文(简体)
复读 A. 对新数据的看法
原标题:refreshing NSTableView with new data multiple times

I have an NSMutableArray and I load my tableview from it. Now I have a Button in the UI which kinda lets the user refresh the data that goes into the array multiple times. And everytime there is new data in the Array I want to refresh the tableView. Just doing [tableView reloadData] after updating the array seems to bring up the beachball. ANy ideas on what would be a good way to achieve this ?

Also I have been taking a look at bindings as a way to implement my NSTableView from an array but all the examples shown online use bindings when they want to add data to their tables ? Can anyone point me on how I could load a array with data into tableView using Bindings ?

如果问题不明确,我愿意读一下,如果有人能够向我提出正确的数据。 感谢: (我不寻求捷径,只是试图从有经验的民间人士那里获得一些关于如何处理这些问题的教益......)

-(IBAction)refreshList:(id)sender
{
//setup array here and sort the array based on one column. This column has 
  identifier  col1  and it works as expected


[aTable reloadData];
  } 

- (int) numberOfRowsInTableView:(NSTableView *)aTable
{ // return count of array
 }

- (id)tableView:(NSTableView *)aTable objectValueForTableColumn: (NSTableColumn *)          
tableColumn row:(int)row
 { 
 //set up arrays here to load data in each column


 }
- (void)tableView:(NSTableView *)aTableView sortDescriptorsDidChange:(NSArray   
 *)oldDescriptors
 {
 //sort here when column headers are clicked
 } 

 -(IBAction)autorefresh:(id)sender
   {

 // Here i am trying to reload the array and refresh the tableView. I want to       
  constantly keep refreshing the array and loading the tableView here. The array does 
  get   refreshed but I am having trouble loading the tableView.


  for ( int i =0; i<=2;i++)
  { 
     // reload the array with data first.
  [aTable reloadData];
    i = 1;

  } 
最佳回答

有了这部法典(特别是你非常新颖的“真正”的路段),你就有一个海滩球,因为你永远不会回到男子的跑步。 在设立可转让的《意见》之后,确定使用守则,每秒1.0秒。

NSTimer* timer = [NSTimer timerWithTimeInterval:1.0
                                         target:[NSApp delegate]
                                       selector:@selector(myReloadData:)
                                       userInfo:nil
                                        repeats:YES];

[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];  

然后产生我的再载荷 贵代表处的数据

- (void)reloadMyData:(NSTimer*)ntp
{
  // reload the array with data first.
  [aTable reloadData];
}
问题回答

如果-reloadData<>/code>正在形成一个海滩球,这几乎肯定意味着控制者执行议定书是错误的。 你们需要说明为什么会发生这种情况,并把它固定下来。 如果你把表格数据来源编码放在桌面上,那么我们或许可以帮助你找出原因。

我高度建议你熟悉“标准”<代码>,甚至在考虑约束之前,可读取<>数据来源和代表方法。 可可 具有约束力的条约是一个相对先进的议题,在你转向具有约束力的条约之前,像你一样需要更基本的可可经验。

尽管如此,该网页有一整套具有可可约束力的实例:

rel=“nofollow noretinger”http://homepage.mac.com/mmalc/CocoaExamples/ Controllers.html

www.un.org/Depts/DGACM/index_spanish.htm 自您发表以来的最新情况:。

我必须假设,你故意不执行上述法典中的数据来源方法,因为你在未经警告的情况下张贴了该守则。

你的汽车法是一种无限的 lo。 这将解释沥青。 您正在制订<条码>i至1>,说明休息时间的长短,这意味着最终条件从未达到。

但是,使用<>条码> 如同这种循环一样,是一种可怕的、可怕的方式,可以恢复表态,并将阻碍主线。 如果您需要经常更新表格,则使用在一定间隔时间使用的NStimer





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签