사용자가 사용자 이름과 암호를 입력 할 수있는 간단한 로그인보기를 위해 mysql 데이터베이스를 xcode 프로젝트에 연결하려고합니다. 이미 데이터베이스를 설정했지만 JSON을 사용해야합니까?
<?php
// Create connection
$con=mysqli_connect("localhost","username","password","dbname");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// This SQL statement selects ALL from the table 'Locations'
$sql = "SELECT * FROM Locations";
// Check if there are results
if ($result = mysqli_query($con, $sql))
{
// If so, then create a results array and a temporary one
// to hold the data
$resultArray = array();
$tempArray = array();
// Loop through each row in the result set
while($row = $result->fetch_object())
{
// Add each row into our results array
$tempArray = $row;
array_push($resultArray, $tempArray);
}
// Finally, encode the array to JSON and output the results
echo json_encode($resultArray);
}
// Close connections
mysqli_close($con);
?>
이에 대한 좋은 기사가 있습니다.
[1] : http://codewithchris.com/iphone-app-connect-to-mysql-database/#parsejson Xcode JSON
나는 xcode에 너무 많은 시간을 소비하지 않았지만 내가 아는 바에 따르면 MySQL 데이터베이스에 연결하기위한 기본 API / 프레임 워크가 없습니다 (대부분의 다른 프레임 워크와 함께). 그렇습니다. JSON 코드를 생성하는 웹 페이지가있는 데이터베이스로 웹 사이트 / 서버를 설정해야합니다. 그런 다음 xcode가 서버 / 웹 페이지에 웹 요청을 보내고 JSON 코드를 변수에 저장 한 다음 xcode가 JSON 데이터를 사용 / 조작하는 데 필요한 모든 방법을 사용합니다. xcode와 웹 서버 모두 적절한 보안 권한이있는 데이터를 서로 전달하는 것을 방해하지 않는지 확인해야합니다.
JSON, CSV 또는 XML 등 원하는 형식으로 데이터를 xcode 앱에 전달할 수 있습니다. xcode의 기능이 무엇이든 고수해야합니다. 실제로 자신 만의 데이터 형식을 구성 할 수도 있습니다. 그것은 여러분의 응용 프로그램이고, xcode에서 가장 쉽게 작업 할 수있는 모든 작업을 수행합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다