Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > iOS ต้องการวิธีการเก็บ ค่า เข้า array ทำยังไงคับ ด่วนนนนนนนนนนนนนน



 

iOS ต้องการวิธีการเก็บ ค่า เข้า array ทำยังไงคับ ด่วนนนนนนนนนนนนนน

 



Topic : 118153



โพสกระทู้ ( 25 )
บทความ ( 0 )



สถานะออฟไลน์




คือ มี ปุ่มให้กด 10 ปุ่ม แล้ว ถ้ากด ปุ่ม ที่ 1,2,3 ให้มันเก็บค่า 1,2,3 ไว้ใน array นะคับ (แต่ละปุ่มมีค่าแล้ว อยากรุ้จะเก็บยังไง ขอแบบเข้าใจง่ายคับขอบคุณคับ)



Tag : Mobile, iOS, iPhone, iPad, Mac







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-08-02 03:15:33 By : peatza130 View : 1138 Reply : 9
 

 

No. 1



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ปล. ขอโทษตอบผิดกระทู้

ใช้ โปรแกรม อะไรเขียนครับ มันมีหลายโปรแกรมที่ไว้ใช้เขียน mobile








ประวัติการแก้ไข
2015-08-02 09:04:05
2015-08-02 09:06:00
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-02 08:31:53 By : NewbiePHP
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ถ้า iOS บน Xcode ลองดู NSArray ครับ

Code (Objective-C)
NSMutableArray *brokenCars = [NSMutableArray arrayWithObjects:
                              @"Audi A6", @"BMW Z3",
                              @"Audi Quattro", @"Audi TT", nil];
[brokenCars addObject:@"BMW F25"];
NSLog(@"%@", brokenCars);       // BMW F25 added to end
[brokenCars removeLastObject];
NSLog(@"%@", brokenCars);   


iOS/iPhone and JSON (Create JSON and JSON Parsing, Objective-C)

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-02 11:11:00 By : mr.win
 

 

No. 3



โพสกระทู้ ( 25 )
บทความ ( 0 )



สถานะออฟไลน์


ขอโทษคับ โปรแกรม xcode คับ admin คับ ของผม

Code (Objective-C)
    brokenCars = [NSArray arrayWithObjects:nil];
    [brokenCars addObject:newJSon[@"obj"][indexPath.row][@"ip_address"]];


แล้ว log ออกมาแค่ตัวสุดท้ายนะคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-02 12:16:17 By : peatza130
 


 

No. 4



โพสกระทู้ ( 25 )
บทความ ( 0 )



สถานะออฟไลน์


 nslog แล้วมันออกมาแค่ ค่าตัวสุดท้ายที่ กดนะคับ เช่น กดตัวที่ 1 2 3 ออกมาแค่ตัวที่ 3 นะคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-02 12:17:21 By : peatza130
 


 

No. 5



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

http://stackoverflow.com/questions/3698152/how-to-append-values-to-an-array-in-objective-c
ลองดูครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-02 12:24:02 By : NewbiePHP
 


 

No. 6



โพสกระทู้ ( 25 )
บทความ ( 0 )



สถานะออฟไลน์


Code (Objective-C)
//
//  ViewController.m
//  searchBarPHPMySQLJSON
//
//  Created by Weerachai on 12/4/55 BE.
//  Copyright (c) 2555 Weerachai. All rights reserved.
//

#import "TBCheckbox.h"
#import "GlobalData.h"

@interface TBCheckbox(){
    NSMutableData *receivedData;
    NSDictionary *newJSon;
    NSMutableArray *myArray;
}
@property (nonatomic, strong) NSMutableArray *DataIP;
@end

@implementation TBCheckbox
{
    UIAlertView *loading;
    BOOL isFiltered;
    NSMutableArray *FilteredString;
   // NSMutableArray *brokenCars;
    NSMutableArray *a;
    NSString *test;
    NSArray *test1;
    UITapGestureRecognizer *dismissKeybaordTap;
}
- (void) viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"List IP";
    NSLog(@"TBShowIP");
    }
- (void)viewWillAppear:(BOOL)animated {
    [super viewDidLoad];

    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://202.44.47.47/mac/show_ipall.php"]]];
    NSData *Data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    newJSon = [NSJSONSerialization JSONObjectWithData:Data options:0 error:nil];
    //NSLog(@"wired offline - %@", newJSon );
    
    _DataIP = [[NSMutableArray alloc] initWithObjects:nil];
    //    NSLog(@"newJson: %@",newJSon[@"obj"]);
    for (NSDictionary *dataDict in newJSon[@"obj"]){
        NSString *IP_SHOW = [dataDict objectForKey:@"ip_address"];
        //        NSLog(@"for %@",IP_SHOW);
        
        [_DataIP addObject:IP_SHOW];
    }
    
    //    NSLog(@"DataIP %@",_DataIP);
    
    
    NSInteger lastcount = [newJSon[@"obj"] count]-1;
    NSLog(@"lostcount: %li",(long)lastcount);
    Global_lastip = newJSon[@"obj"][lastcount][@"ip_address"];
    NSLog(@"last obj: %@",_DataIP[lastcount]);
}

- (void)toggleCells:(UIRefreshControl*)refreshControl
{
    [refreshControl beginRefreshing];
    //    self.refreshControl.tintColor = [UIColor blueColor];
    [self.TableView reloadData];
    [refreshControl endRefreshing];
}

///////////////////////////////////////////////////////////////////////
////////////                                            ///////////////
////////////                set data                    ///////////////
////////////                                            ///////////////
///////////////////////////////////////////////////////////////////////

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger selectedRow = indexPath.row;
    NSLog(@"touch on row %ld / Data: %@", (long)selectedRow,newJSon[@"obj"][indexPath.row][@"ip_address"]);
    myArray = [NSMutableArray array];
        [myArray addObject:[NSString stringWithString:newJSon[@"obj"][indexPath.row][@"ip_address"]]];
    NSLog(@"myArray:\n%@", myArray);
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger selectedRow = indexPath.row;
    NSLog(@"touch off row %ld / Data: %@", (long)selectedRow,newJSon[@"obj"][indexPath.row][@"ip_address"]);
}
- (IBAction)click:(id)sender
{
    [_TableView setEditing:YES animated:YES];
    
}
- (IBAction)click2:(id)sender
{
    [_TableView setEditing:NO animated:YES];
}
- (IBAction)click3:(id)sender
{
    NSLog(@"myArray2:\n%@", myArray);
}

///////////////////////////////////////////////////////////////////////
////////////                                            ///////////////
////////////             remove data                    ///////////////
////////////                                            ///////////////
///////////////////////////////////////////////////////////////////////

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 3;
}
///////////////////////////////////////////////////////////////////////
////////////                                            ///////////////
////////////             Select data                    ///////////////
////////////                                            ///////////////
///////////////////////////////////////////////////////////////////////
#pragma mark * Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    // If you're serving data from an array, return the length of the array:
    if (isFiltered) {
        return [FilteredString count];
    }
    return [newJSon[@"obj"] count];
    // return (nil == self.fruits) ? 0 : [self.fruits count];
    
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];//forIndexPath:indexPath]
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        [[cell detailTextLabel] setNumberOfLines:0]; 
        [[cell detailTextLabel] setFont:[UIFont systemFontOfSize: 14.0]];
    }

    cell.textLabel.text = newJSon[@"obj"][indexPath.row][@"ip_address"];
       cell.detailTextLabel.text = @"";
    cell.tintColor = [UIColor redColor];
    cell.accessoryType =  UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    receivedData = [[NSMutableData alloc] init];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    sleep(5);
    [receivedData appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    // inform the user
    UIAlertView *didFailWithErrorMessage = [[UIAlertView alloc] initWithTitle: @"NSURLConnection " message: @"didFailWithError"  delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
    [didFailWithErrorMessage show];
    
    //inform the user
    NSLog(@"Connection failed! Error - %@", [error localizedDescription]);
    
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [loading dismissWithClickedButtonIndex:0 animated:YES];
    
    
    if(receivedData)
    {
        NSString *dataString = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];
        NSLog(@"dataString: %@",dataString);
        
        UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"" message:dataString  delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [connectFailMessage show];
    }
    
    // release the connection, and the data object
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-03 04:19:52 By : peatza130
 


 

No. 7



โพสกระทู้ ( 25 )
บทความ ( 0 )



สถานะออฟไลน์


มันเก็บแค่ตัวสุดท้ายที่ กดเหมือนเดิมนะคับ เมื่อกด มันจะทำงาน บรรทัดที่ 76 นะคับ แล้ว พอกด ปุ่มตกลง จะมาทำงานบรรทัดที่ 98

ถ้าสมมุติผม กด check box หลาย อัน มันก็ต้อง เก็บข้อมูลหลายอัน แต่นี้มันเก็บแค่อันสุดท้ายที่เรากดอะคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-03 04:22:52 By : peatza130
 


 

No. 8



โพสกระทู้ ( 1,636 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

080. myArray = [NSMutableArray array];
บันทัดนี้ เป็นการเซทค่าใหม่ หรือเปล่าครับ เหมือนกับไม่ได้อ่านค่าเก่ามาใช้นะครับ
น่าจะประกาศเป็น global ไว้หรือเปล่าครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-03 10:23:20 By : NewbiePHP
 


 

No. 9



โพสกระทู้ ( 25 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วคับขอบคุณคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-03 13:29:16 By : peatza130
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : iOS ต้องการวิธีการเก็บ ค่า เข้า array ทำยังไงคับ ด่วนนนนนนนนนนนนนน
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่