A TKSmartCard object represents a Smart Card. The TKSmartCard class provides an interface for managing sessions with a Smart Card, transmitting requests, and facilitating user interaction.


You can create a TKSmartCard object when a Smart Card is inserted into a slot, by calling the makeSmartCard method on the corresponding TKSmartCardSlot object. To start communicating with the Smart Card, call the beginSessionWithReply: method on the TKSmartCard object. Once an exclusive session has been established, you transmit data using the transmitRequest:reply: method. After you’ve finished communicating with a Smart Card, you call the endSession method.

If the Smart Card is physically removed from its slot, the session object becomes invalid, and any further calls to transmitRequest:reply: will return an error. You can use Key-Value Observing on the valid property to be notified when a Smart Card is invalidated, due to being removed from the slot or another reason.


Configuring the Smart Card


The slot in which the Smart Card is inserted.


Whether the Smart Card is valid and accessible from its slot.


The protocols allowed for communication with the Smart Card. TKSmartCardProtocolAny by default.


The protocol used for communication with the Smart Card. Returns TKSmartCardProtocolNone if no session is currently established.


Whether sessions established for the Smart Card should be considered sensitive. NO by default.


User-specified information. This property is automatically set to nil if the Smart Card is removed or another TKSmartCard object begins a session.

Communicating with the Smart Card

- beginSessionWithReply:

Begins a session with the Smart Card.

- transmitRequest:reply:

Transmits data in Application Protocol Data Unit (APDU) format to the Smart Card.

- endSession

Completes any pending transmissions and ends the session to the Smart Card.

Managing User Interaction

- userInteractionForSecurePINVerificationWithPINFormat:APDU:PINByteOffset:

Creates and returns a new user interaction object for secure PIN verification using the Smart Card reader facilities.

- userInteractionForSecurePINChangeWithPINFormat:APDU:currentPINByteOffset:newPINByteOffset:

Creates a new user interaction object for secure PIN change using the smart card reader facilities (typically a HW keypad).

Configuring APDU Behavior


The CLA byte used for APDU transmission. 0x00 by default.


Whether to use extended length APDU.


Whether to use command chaining of APDU with a data field longer than 255 bytes.

Transmitting APDU

- sendIns:p1:p2:data:le:reply:

Asynchronously transmits a specified APDU to the Smart Card and returns a response.

- sendIns:p1:p2:data:le:sw:error:

Synchronously transmits a specified APDU to the Smart Card and returns a response.

- inSessionWithError:executeBlock:

Synchronously begins a session, executes the given block, and ends the session.


Inherits From