-2

皆さんこんにちは

私が持っているアプリケーションを生成しています4 fields ( product id, product name, product price, product description)

ここで、データを保存するときに製品 ID が自動的に生成されるようにします。つまり、アプリを実行すると、製品 ID のテキスト フィールドが自動的に生成され、保存ボタンをクリックすると、この ID が 1 ずつ増加し、ID がの最後のデータを保存する必要があります。

親切に私を助けてください。

4

3 に答える 3

0

NSUserDefaults で達成したい場合は、次のコードを使用します

// get total count   
int count=[[NSUserDefaults standardUserDefaults]integerForKey:@"TotalIdCount"];


// on save button click increment count by one and stored it
count=count+1;
[[NSUserDefaults standardUserDefaults ] setInteger:count forKey:@"TotalIdCount"];
[[NSUserDefaults standardUserDefaults] synchronize];
于 2013-10-17T12:05:50.430 に答える
0

このチュートリアルを見る必要があります

http://upadhyayajayiphone.blogspot.in/2012/11/insert-record-in-sqlite-table-get.html

http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application

すべての操作が含まれています。SELECT MAX(product_id) from TABLE_NAMEデータをフェッチしている間、最後のデータをフェッチするために使用します。

于 2013-10-17T12:01:19.613 に答える