Explain the concept of optionals in Swift.

CMPTR
3rd Edition
ISBN:9781337681872
Author:PINARD
Publisher:PINARD
Chapter20: Creating A Presentation
Section: Chapter Questions
Problem 2QY
icon
Related questions
Question
Explain the concept of optionals in Swift.
Transcribed Image Text:Explain the concept of optionals in Swift.
What are the purpose and the output produced by the following code fragment?
a) Android
//public class databaseHelper
public Integer deleteRecord (String id) {
SQLiteDatabase db = this.getWritableDatabase();
return db.delete("MyTable", "ID = ?",new String[] {id});
// MainActivity.java - method myMethod ()
databaseHelper myDB = new databaseHelper (this, null, null, 1);
EditText txtID = (EditText) findViewById(R.id.txtID);
Integer nRow = myDB.deleteRecord (txtID.getText().toString());
if (nRow > 0) {
Toast.makeText (MainActivity. this, "Success!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText (MainActivity. this, "Error", Toast.LENGTH_LONG).show();
}
Transcribed Image Text:What are the purpose and the output produced by the following code fragment? a) Android //public class databaseHelper public Integer deleteRecord (String id) { SQLiteDatabase db = this.getWritableDatabase(); return db.delete("MyTable", "ID = ?",new String[] {id}); // MainActivity.java - method myMethod () databaseHelper myDB = new databaseHelper (this, null, null, 1); EditText txtID = (EditText) findViewById(R.id.txtID); Integer nRow = myDB.deleteRecord (txtID.getText().toString()); if (nRow > 0) { Toast.makeText (MainActivity. this, "Success!", Toast.LENGTH_LONG).show(); } else { Toast.makeText (MainActivity. this, "Error", Toast.LENGTH_LONG).show(); }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Distributed Database Concepts
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage