Visualizing wave interference with FireMonkey
Monday, January 30th, 2012My article "Visualizing wave interference using FireMonkey" on EDN.
My article "Visualizing wave interference using FireMonkey" on EDN.
Getting data out of the iOS address book is a lot harder than I thought… Must make component…
Here’s a Q&D routine I managed to eek out today. It simply prints all contacts and all their numbers to the log console.
Enjoy!
uses
iPhoneAll, AddressBook, CFArray, CFBase;
procedure DumpAddressBook;
var
addressBook : ABAddressBookRef;
allPeople : CFArrayRef;
nPeople : CFIndex;
ref : ABRecordRef;
i, j : Integer;
firstName : CFStringRef;
lastName : CFStringRef;
phoneNumber : CFStringRef;
l, v : CFStringRef;
S : NSString;
begin
addressBook := ABAddressBookCreate;
allPeople := ABAddressBookCopyArrayOfAllPeople(addressBook);
nPeople := ABAddressBookGetPersonCount(addressBook);
for i:=0 to nPeople-1 do begin
ref := CFArrayGetValueAtIndex(allPeople,i);
firstName := ABRecordCopyValue(ref,kABPersonFirstNameProperty);
lastName := ABRecordCopyValue(ref,kABPersonLastNameProperty);
if firstName <> nil then
if lastName <> nil then
S := NSString.stringWithFormat(NSSTR(PChar('%@, %@')),lastName,firstName)
else
S := NSString.stringWithFormat(NSSTR(PChar('%@')),firstName)
else
if lastName <> nil then
S := NSString.stringWithFormat(NSSTR(PChar('%@')),lastName);
NSLog(S);
phoneNumber := ABRecordCopyValue(ref, kABPersonPhoneProperty);
for j:=0 to ABMultiValueGetCount(phoneNumber)-1 do begin
l := ABMultiValueCopyLabelAtIndex(phoneNumber,j);
v := ABMultiValueCopyValueAtIndex(phoneNumber,j);
S := NSString.stringWithFormat(NSSTR(PChar('%@: %@')),l,v);
NSLog(S);
CFRelease(l);
CFRelease(v);
end;
if phoneNumber <> nil then
CFRelease(phoneNumber);
if firstName <> nil then
CFRelease(firstName);
if lastName <> nil then
CFRelease(lastName);
end;
end;
I’ve added a component to handle left, right, up and down swipe gestures to my set of iOS components.
NOTE: This component requires that you edit the FMX_Platform_iOS.pas file on the Xcode side to surface mainWindow and a few other things.
Once installed, this component is extremely easy to use. Simply hook up the OnSwipe events that you’d like to handle and you’re done!
type TSwipeEvent = procedure of object; TiOSSwipeGestureRecognizer = class(TFmxObject) private FOnSwipeRight : TSwipeEvent; FOnSwipeLeft : TSwipeEvent; FOnSwipeUp : TSwipeEvent; FOnSwipeDown : TSwipeEvent; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property OnSwipeRight: TSwipeEvent read FOnSwipeRight write FOnSwipeRight; property OnSwipeLeft: TSwipeEvent read FOnSwipeLeft write FOnSwipeLeft; property OnSwipeUp: TSwipeEvent read FOnSwipeUp write FOnSwipeUp; property OnSwipeDown: TSwipeEvent read FOnSwipeDown write FOnSwipeDown; end;
Enjoy!
We’re looking for an Architect to join the RAD Studio Team.
Embarcadero Technologies is seeking an Architect to join the leadership staff of FireMonkey, Embarcadero’s next generation business application platform. The FireMonkey platform helps you build spectacular applications that are faster, more visually stunning, and more connected – all with native performance on Windows, Mac, and iOS.
Bad Behavior has blocked 512 access attempts in the last 7 days.