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 > Windows Azure > Windows Azure (Mobile Services) and iOS (iPhone , iPad) > ตอนที่ 4 : สร้าง Project iOS / iPhone และการเชื่อมต่อกับ Library ของ Mobile Services



Clound SSD Virtual Server

ตอนที่ 4 : สร้าง Project iOS / iPhone และการเชื่อมต่อกับ Library ของ Mobile Services

ตอนที่ 4 : สร้าง Project iOS / iPhone และการเชื่อมต่อกับ Library ของ Mobile Services ในบทความนี้จะเป็นหัวข้อเกี่ยวกับการสร้าง Project บน Xcode หรือในกรณีที่มี Project อยู่แล้ว แต่ต้องการเรียกใช้งาน Library หรือ Mobile Service SDK for iOS ด้วยการ Download ไฟล์ iOS SDK จากเว็บไซต์ของ Windows Azure และทำการ Import ตัว Library เข้ามาใน Project จากนั้นค่อนเขียน Code ต่าง ๆ บน Xcode เพื่อทำการเชื่อมต่อไปยัง Mobile Services ที่อยู่บน Windows Azure

iOS Connect Mobile Services

สร้าง Project บน Xcode หรือในกรณีที่มี Project อยู่แล้วให้ข้ามขั้นตอนนี้ไปได้เลย

iOS Connect Mobile Services

เลือก Single View Application

iOS Connect Mobile Services

กรอกรายละเอียดต่าง ๆ และที่สำคัญให้เลือก Devices เป็นแบบ iPhone

iOS Connect Mobile Services

เลือกจัดเก็บที่ Desktop








iOS Connect Mobile Services

ตอนนี้เราได้โฟเดอร์ Project ขึ้นมาแล้ว

iOS Connect Mobile Services

กลับไปยัง Project บน Xcode ตอนนี้เราจะพบกับโครงสร้างของไฟล์ต่าง ๆ เช่น .h และ .m และจะมี Framework ที่เป็นค่า Default มาด่วย 3 ตัว

iOS Connect Mobile Services

ตอนนี้ให้เราทดาอบรัน Project บน Simulator

iOS Connect Mobile Services

ตอนนี้หน้าจอ View ยังว่าง ๆ เป็นทีเทา

iOS Connect Mobile Services

ให้เราปรับแต่ง View ที่ไฟล์ ViewController.xib ในส่วนของ Inspector ให้เลือก Background เปลี่ยนเป็นสีขาว


กลับมายังหน้าจอ Mobile Services บน Windows Azure

iOS Connect Mobile Services

เลือก Mobile Services ที่เราได้สร้างขึ้นไว้ก่อนหน้านี้

iOS Connect Mobile Services

เลือก CONNECT AN EXISTING IOS APP จากนั้นทำตามขั้นตอนด้วยการ Download ไฟล์ "Download the iOS SDK"

iOS Connect Mobile Services

ได้ไฟล์เป็น .zip เรียร้อยแล้ว

iOS Connect Mobile Services

แตกไฟล์ซึ่งเราจะได้ไฟล์ดังรูป

iOS Connect Mobile Services

ให้ทำการลากไฟล์ดังกล่าวไปไว้ที่ Framework ของ Project บน Xcode

iOS Connect Mobile Services

คลิกเลือก "Copy items into destination group's folder (if needed)"

iOS Connect Mobile Services

ตอนนี้ Framework สำหรับไว้เชื่อมต่อกับ Mobile Services ถูก Add เข้ามาใน Project เรียบร้อยแล้ว
ต่อไปเราจะทดสอบเชื่อมต่อระหว่าง [b]iOS กับ Mobile Services บน Windows Azure และแสดงสถานะการเชื่อมต่อบน Label[/b]

iOS Connect Mobile Services

ลาก Label มายังหน้าจอ View

iOS Connect Mobile Services

ทำการเชื่อม IBOutlet กับ IBAction ให้เรียบร้อย

iOS Connect Mobile Services

ใน Windows Azure แนะนำให้ทำการ import และเรียกใช้งานดังรูป

iOS Connect Mobile Services

ให้เราคลิกที่ ViewController.h แล้ว import ไฟล์ และประกาศตัวแปรดังรูป

//
//  ViewController.h
//  myAppMobileService
//
//  Created by Weerachai on 5/12/56 BE.
//  Copyright (c) 2556 Weerachai. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <WindowsAzureMobileServices/WindowsAzureMobileServices.h>

@interface ViewController : UIViewController
{
    IBOutlet UILabel *lblStatus;
}

@property (nonatomic, strong)   MSClient *cl;

@end


iOS Connect Mobile Services

และไฟล์ ViewController.m เขียนคำสั่งเพื่อติดต่อกับ Mobile Services ของ Windows Azure

//
//  ViewController.m
//  myAppMobileService
//
//  Created by Weerachai on 5/12/56 BE.
//  Copyright (c) 2556 Weerachai. All rights reserved.
//

#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    MSClient *client = [MSClient clientWithApplicationURLString:@"https://thaicreate.azure-mobile.net/"
                                                 applicationKey:@"JbRsrGvytUSWWmfKkoqukDmLYzERpl40"];
    
    self.cl =[client clientWithFilter:self];
    
    if (self.cl !=  [NSNull null]) {
        lblStatus.text = @"iOS Mobile Service Connected";
    }
    else
    {
        lblStatus.text = @"iOS Mobile Service Connect Failed";
    }
    
}

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

- (void)dealloc {
    [lblStatus release];
    [super dealloc];
}
@end

จะเห็นว่าที่สำคัญจะมีตรง clientWithApplicationURLString และ applicationKey ซึ่งอันนี้จะผิดไม่ได้

Screenshot

iOS Connect Mobile Services

ทดสอบการทำงานจะได้ผลพังรูป ตอนนี้ iOS สามารถติดต่อกับ Mobile Services ของ Windows Azure เรียบร้อยแล้ว และบทความถัดไป เราจะมารู้วิธีการ Insert ข้อมูลไปจัดเก็บไว้ที่ Mobile Services ของ Windows Azure








บทความถัดไปที่แนะนำให้อ่าน


บทความที่เกี่ยวข้อง


   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2013-06-15 19:49:57 / 2017-03-24 11:44:54
  Download : Download  ตอนที่ 4 : สร้าง  Project iOS / iPhone และการเชื่อมต่อกับ Library ของ Mobile Services
 Sponsored Links / Related

 
ตอนที่ 1 : รู้จัก iOS กับ Mobile Services บน Windows Azure คืออะไร
Rating :

 
ตอนที่ 2 : เตรียมความพร้อมของ iOS / iPhone ก่อนที่จะเขียนบน Mobile Services
Rating :

 
ตอนที่ 3 : การสร้าง iOS / iPhone กับ Mobile Services และการเรียกใช้งานแบบง่าย ๆ
Rating :

 
ตอนที่ 5 : iOS / iPhone สร้างตาราง Table บน Mobile Services และการ Insert ข้อมูล
Rating :

 
ตอนที่ 6 : iOS / iPhone อ่าน Data จาก Table ของ Mobile Service และแสดงผลบน App
Rating :

 
ตอนที่ 7 : อ่านข้อมูล Mobile Services แบบมีเงื่อนไข Where และแสดงผล iOS / iPhone
Rating :

 
ตอนที่ 8 : การทำ Authentication in Azure Mobile Services ด้วย iOS / iPhone
Rating :

 
ตอนที่ 9 : การทำ Push Notifications in Mobile Services ด้วย iOS / iPhone
Rating :

 
ตอนที่ 10 : การทำ Validate และ Modify data in Mobile Services บน iOS / iPhone
Rating :

 
ตอนที่ 11 : การทำ Refine Mobile Services queries with paging บน iOS / iPhone
Rating :

 
ตอนที่ 12 : การเขียน Scripts to authorize users in Mobile Services บน iOS / iPhone
Rating :

 
ตอนที่ 13 : Show Case 1 : Register Form (iOS / iPhone and Mobile Services)
Rating :

 
ตอนที่ 14 : Show Case 2 : Login User Password (iOS / iPhone and Mobile Services)
Rating :

 
ตอนที่ 15 : Show Case 3 : Update Data (iOS / iPhone and Mobile Services)
Rating :

 
ตอนที่ 16 : Show Case 4 : Delete Data (iOS / iPhone and Mobile Services)
Rating :

 
ตอนที่ 17 : บทความอื่น ๆ เกี่ยวกับ iOS / iPhone Mobile Services บน Windows Azure
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
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 อัตราราคา คลิกที่นี่