Search This Blog

Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Friday, November 19, 2010

iOS SDK Text To Speech in one line

Peace be upon you

How are you guys? I am so glade that I am writing to you, todays post will be short and hopefully useful.

While I was digging in iOS's private frameworks one library caught my attention, "VoiceServices" after some playing around it I found that there is away to use the "VoiceOver" capabilities out of its context, Here is video explaining the whole thing.


Here is the code for it.

[[[NSClassFromString(@"VSSpeechSynthesizer") new]autorelease] startSpeakingString:@"I like to speak everywhere"];


As you can see, with this line u can make the iOS speak whatever to you, just find useful use for it, something to read the twits or RSS feeds.


Enjoy :)


BR

Ahmed Essam

Thursday, November 04, 2010

Extending TBXML

Peace be upon you

How are you my beloved reader :)? I hope things is going Ok with you.

today I have added something to the library "TBXML" to extend the functionality to help reading XML in easier way.
Here is link for the library http://tbxml.co.uk/

the functions that I have wrote simply reads the XML and turn it into "Dictionary (Hash table)" the functions that I have wrote neglects the attributes, such code will help transforming the complex hierarchy of XML into dictionary that has key value (the value code be string, array or another dictionary )

Here is the code that I have added to the library (Add this code to the class "TBXML")


+ (NSMutableDictionary*) getXMLNodeInDictionary:(TBXMLElement *)element {

NSMutableDictionary* retDict = [NSMutableDictionary new];

do {

if (element->firstChild) {

if ([retDict valueForKey:[TBXML elementName:element]]==nil) {

[retDict setObject:[self getXMLNodeInDictionary:element->firstChild] forKey:[TBXML elementName:element]];

}else if ([[retDict valueForKey:[TBXML elementName:element]] isKindOfClass:[NSMutableArray class]]) {

[[retDict valueForKey:[TBXML elementName:element]] addObject:[self getXMLNodeInDictionary:element->firstChild]];

}else {

NSMutableArray* arr = [NSMutableArray new];

[arr addObject:[retDict valueForKey:[TBXML elementName:element]]];

[arr addObject:[self getXMLNodeInDictionary:element->firstChild]];

[retDict setObject:[arr autorelease] forKey:[TBXML elementName:element]];

}

}else {

[retDict setObject:[TBXML textForElement:element] forKey:[TBXML elementName:element]];

}

} while ((element = element->nextSibling));

return [retDict autorelease];

}


+ (NSMutableDictionary*)getXMLFileInDictionary:(NSString*)filenameWithFullPath{

NSString* str = [[NSString alloc]initWithContentsOfFile:filenameWithFullPath];

TBXML * tbxml = [TBXML tbxmlWithXMLString:str];

if (!tbxml.rootXMLElement) {

return nil;

}

return [self getXMLNodeInDictionary:tbxml.rootXMLElement];

}




Thanks for your time :)


BR

Ahmed Essam

Friday, August 06, 2010

Right To Left iPhone UI

Peace be upon you.

I have been working on Arabic Apps for iPhone, sometimes I need to do things quickly rather than making the whole UI components from the beginning, I came up with good trick to enable me doing Right To Left UIs with minimum effort, it is not perfect but it is working just fine.

There is something in Core Graphics called Affine transformations , this set of function all you doing anything related to image manipulation, as the UI elements turned to be image at the end, the property "transform", it has the typical 2d Array of image manipulation

based on that fact I started playing with the UI controls here is what I have got playing with the tab bar controller and Table view controller


Normal view, no changes , as u can see the tabs aren't arrange in the Arabic Logic

I started by "rotating" the whole bar 180º

I did loop through the buttons and rotate them 180º so it end up with correct view for the view, flipping flipped image makes it look correct

I have added more than 5 tabs and I have got the same thing with the more button, the items are viewed from left to right


I did loop through the cell of the table and I did rotation for the whole cell, then correcting the text by rotating it 180º .

The thing is little bit UI buggy but with some time it can be fixed to look Ok,
here is the code for this thing, All U have to do is replacing the code for the function "didFinishLaunchingWithOptions"




UIViewController* cont1 = [[UIViewController alloc]init];

UIViewController* cont2 = [[UIViewController alloc]init];

UIViewController* cont3 = [[UIViewController alloc]init];

UIViewController* cont4 = [[UIViewController alloc]init];

UIViewController* cont5 = [[UIViewController alloc]init];

UIViewController* cont6 = [[UIViewController alloc]init];

UINavigationController* contBar = [[UINavigationController alloc] initWithRootViewController:cont1];

contBar.tabBarItem.title = @"واحد";

cont2.tabBarItem.title = @"أثنين";

cont3.tabBarItem.title = @"ثلاث";

cont4.tabBarItem.title = @"أربع";

cont5.tabBarItem.title = @"خمس";

cont6.tabBarItem.title = @"سته";

cont1.view.backgroundColor = [UIColor redColor];

cont2.view.backgroundColor = [UIColor blueColor];

cont3.view.backgroundColor = [UIColor grayColor];

cont4.view.backgroundColor = [UIColor purpleColor];

cont5.view.backgroundColor = [UIColor yellowColor];

const id objs[6] = { contBar,cont2,cont3,cont4,cont5,cont6};

NSArray* vuCont = [NSArray arrayWithObjects:objs count:6];

tabBarController.viewControllers = vuCont;

tabBarController.tabBar.transform = CGAffineTransformMakeRotation(3.142857142857143);


for (id d in tabBarController.tabBar.items) {

UIView* vu = [d valueForKey:@"_view"];

vu.transform = CGAffineTransformMakeRotation(3.142857142857143);

}

UITableView* tbl = [tabBarController.moreNavigationController.topViewController view];

tbl.separatorColor = [UIColor clearColor];

for (UITableViewCell* cl in [[tabBarController.moreNavigationController.topViewController view] visibleCells]) {

cl.transform = CGAffineTransformMakeRotation(180*0.0174532925);

cl.textLabel.transform = CGAffineTransformMakeRotation(180*0.0174532925);

cl.textLabel.textAlignment = UITextAlignmentRight;


}


[window addSubview:tabBarController.view];

[window makeKeyAndVisible];


return YES;




Thanks for your time :)


Ahmed Essam

Wednesday, March 03, 2010

My Session Resource (Cairo Code Camp 2010)

Peace be upon you
How are you guys? First of all I would like to thank everyone at Cairo Code Camp, I really enjoyed ever minute there.
Here is the most amazing part, I gave a session at Cairo Code camp about iPhone development using C#, I thought that few people will be interested in such thing and the amazing thing is, the hall was full of people + there was some people setting on the ground (not a lot but it happen :D ), I have got amazing feed backs, I really can't believe that such thing happen :D, I would agree if 10 people attend the session :D but I got about 150 which is great, Now I am officially a technical speaker :).
anyways, Here is the source code and the presentation, I hope you like it.
Here is the path for the folder
MonoTwit fitch the timeline and post twits
MonoFlick Search for keyword and view the photos
I hope you like the slides, thanks for your time :)
BR
Ahmed Essam

Monday, December 14, 2009

MARS on iPhone

Peace be upon you

How are you guys? today I am going to show you something I have done as a data security assignment, the assignment was a presentation and application, me and other 3 guys were suppose to write something about MARS and Application, I helped in the Presentation and took the application :D, do you understand anything?

Well, let us begin the whole thing is about encryption algorithm called MARS, developer by IBM, you can find more about it

And here is the presentation


So, the idea is to make application for the ready made code of IBM, so the plane was todo simple application that do simple encryption and decryption, here is snapshots for the application, you can find the code here (Cocoa Touch Objective C project)

Lets see the application.

The application starts with the operation, you have to select wither you want to encrypt or decrypt
Enter the operation Key, in this case the "Encryption key"
Enter the data that you want to encrypt.
Here is the result, and as we use OFB + Random IV, when you reencrypt by just clicking back and next, you will get anther result
HEre is anther result for the encryption due to the IV + OFB
3rd result , Thanks to the OFB and IV
Save the file

Lets do decryption for what we have encrypted
Select Decryption
Then enter the key
Select the file name, you can enter free text in this page.
Now you have got your data


I have added little part for some fun it is the Mode of Operation , you can read more about it here

The mode that I have used was "OFB, output feed back"

I hope that you enjoy the application and the presentation :)
Thanks for your time.

BR
Ahmed Essam

Sunday, June 28, 2009

Tethering iPhone over any network

Peace be upon you
I have figured out away to tether your iPhone with any mobile network, let us start

The first thing we will need is to write the configuration file, Here is link for sample configuration file, actually it is working for Egypt Mobinil users

http://cid-e2c1100334a33877.skydrive.live.com/self.aspx/.Public/MISC/eg%7C_mobinil.mobileconfig

Now, for each network it will need little bit of effort to make it work, we have to edit the configuration file, here is snapshot for the keys that is going to be modified


"APN" , this is the string that has the Access Point Gateway, you can get this from the operator, or u can get it from any phone with internet capabilities ,


"password" , This is the access point password, get it from the Operator


"Username", This is the access point username, get it from the Operator

"PayloadIdentifier", becareful with this one, because it may change something that u don't deser, I recommend for this one is to be like this pattern "..profile.apn"


for instance

eg.mobinil.profile.apn

This keys is the keys that have effect and will make your tethering work.


After that, put the file on a Web Server and log to it from Safari mobile and install it













Happy tethering :)


Thanks for your time.


BR

Ahmed Essam

Sunday, June 07, 2009

Cheap way to develop for iPhone

Peace be upon you

How are you guys? I am sorry for not posting a lot.
Today I am gonna write how to start iPhone development in a very cheap way, first let us talk about why, I thought about that.
In Egypt we have don't have Apple it self, we have punch of people who has the reseller logo, they offer SUCK service, high prices for nothing, they are even not cool in manner of human treatment, it is like "we sell Apple products, we are from heaven (YAKHHHHH)"
anyways, I have noticed that people likes the idea of developing for the iPhone and how it can get quite good money for simple application, this is happen because of the huge number which is use 1 place to shop for software "App store", the only thing that makes people step back is the prices of the Apple machines, in Egypt we pay double prices so there is always something to be done to get out of this CRAP, high price and need of equipment, so I have started messing around the netbooks as a low end machines that can do HELL of things (little monster)

so what do u need to start?
 - MSI Wind U123x
 - Externel DVD reader
 - Mac OS X (10.5.2 (this what I have tried) or higher) -> Kalyway (get it from http://wiki.osx86project.org/wiki/index.php/Main_Page )
 - Combo Update to (10.5.3)
 - iPhone SDK (get it for free from http://developer.apple.com/iphone )
 - Chain0 (get it from http://wiki.osx86project.org/wiki/index.php/Chain0 )

Here is snapshots for what the operation 

Insert the Mac OS X Kalyway DVD and boot

From the customize screen select the proper kernel and VGA driver 
Now after installing the combo update (VERY TRICKY to be installed) and installing the XCode and iPhone SDK everything up and running and 100% running 

Screen shot from the MSI Wind U123x after having a simple trail.

I will post in detail how to make everything running, I have exams this days so pray for me and I hope that I have much time for my BELOVED blog and BELOVED readers, I really miss the nice feeling when I write something

Thanks for your time.
BR
Ahmed Essam

Saturday, May 09, 2009

NSOpreation

Peace be upon you

How are you guys? I am sorry that it has been long time since last post, but I have exams, work and my beloved iPhone projects.

Now, let us get to the point of todays post, it is about something called NSOpreation and NSOpreationQueue, this classes are part of the "iPhone Threading programming", which means that this things are mostly used when u do some threading in the iPhone app

The point here that makes me really get stunned was that this thing manages that queue of tasks, it is really critical to have something like that done for you, this thing manages that threads combined with locks combined with queue management, imagine that you have some kind of big thing, I will never have example better than Standford CS193p sample, flicker, imagine that you get some list of information from flicker and u wanna display it, considering that it is coming from the web, it will take some time, so there will be a need to handle it really wisely to make user feels Ok and don't get bored from your application, if I am going to do it on Windows, I may use "Threads", "Locks" to handle it and I think it will be a bit headache.

In the iPhone development "as far as I know such class is not exist for Mac OS yet", this classes will save all that time that will be sucked by implement this stuff, I really recommend downloading the sample and check it out, it is available online on the CS193p page, I really wish that I have some time to write example to show you how much it can be efficient to use such thing.
ohh, I forgot to mention that iPhone considered a subset of unix, which means internally it uses the pthread, I think it has all the POSIX , can u imagine that this little device runs UNIX :D

anyways, it was nice writing to you :) and I hope u like it as I do ;)

thanks for your time.

BR
Ahmed Essam

Tuesday, April 14, 2009

Arabic in iPhone Safari Sourcsecode

Peace be upon you

This days, I have forward my focus into iPhone development, actually I have figured out too many things that I miss by not working for Mac :D
I am not going to get into debate or something like that but all I am going to say is "Apple definition for the word 'Framework' is much much much much better than anyone else"
Let us get to what I am coming to say today.

Today I would like to demonstrate some stuff related to Arabic inside WebKit which the core of Safari
I will sort then explain, as I don't have much time I will explain in hurry :D
First, to get the code , you have to download it from Apple Opensource section, here is link
http://www.opensource.apple.com/darwinsource/iPhone/
in the Article I have used the 2.2.1
so let us start with BiDi related function , this function called BidiCharacterRung, I put it here because I have noticed that it has some kind of detection for the Right To Left issue



shapeArabic, If you know about Arabic representaion, the reshaping is the phase which make the Arabic readable by the user

This line I like very much, this code prevent from showing "boxes" if the font is not exist


The function related to previous figure


  1. The first image shows that the Arabic is really solved in manar of character direct, this doesn't mean RTL, you can notice that in Safari because actually it showes Arabic is resolved and corrected but not Shaped
  2. The code showes that there is some work done in many levels, there is some code also to solve Arabic in the SVG render engine, which means that it is ready, I don't know why they didn't use it, may be it is little buggy
  3. I like this part very very much, in OS X, when you use font that doesn't have the glphy"the shape of the character" of the character, it will find anther font that does have a font containe the character, why this thing is very important, it think it is better to see the character than seeing squares :D, you can easily see this in Windows mobile if it doesn't has Arabic support by 3rd party
What do I think about this code is, this code is somekind of memory conuming, as I understand that the code doubles the buffer to manage to solve the bidi issue
I think it should be optimized some how.
anyways, I like the code it is very well commented, I really recommend you to review it,
it doesn't require any thing from Apple products to review this stuff.

I hope that anyone correct me if there is anything wrong

Thanks for your time.

BR
Ahmed Essam

Thursday, March 26, 2009

iPhone OS 3.0 Has full Arabic Support

Peace be upon you
As you know that I have started my tries with the iPhone and I was very annoied because there is no Arabic Support for this Amazing device, now with iPhone OS 3.0 (the used to call it OS X now they call it iPhone OS) you can read Arabic , check out the images 


Arabic in the local application, it means that the strings are in the application, there is nothing I have done more than showing the string.


in the settings you will see that there is Arabic Key board

Now I have tried to use the Arabic keyboard and it is working "I liked it, but it didn't give right to left"

The best of all "Safari" now the browser supports the Arabic and it is working very nice, it is really nice experience to have.

I will not be able to talk much about the iPhone OS 3.0 because of the Agreement.

I am sorry for the low rate of posting but I promise I will be focusing in the blog soon

Thanks for your time.

BR
Ahmed Essam

Saturday, November 15, 2008

iPhone, Totally joke in Egypt

Peace be upon you 

How are you? I am sorry for long time "unposting", I am busy as hell :D.

anyways, Yesterday iPhone had been released in Egypt, it is nice but it is very bad when you know some details.

in Apple web site you will find this 2 nice logos for our "beloved" Mobile network operators

as far as I remember that Steve Jobs said that the iPhone will not Exceed the 200$, which is more than nice.

Here is the shock coming, when you check the websites for the operators you will see that you will have to pay 
3850 for the 8 G, which means 692 USD, :D
4450 for the 16 G, which means 800 USD :D:D:D:D:D

check the below snaps from the web sites
Vodafone "OFFER"

Mobinil Offer

The nice thing is after you pay all that money, you can't use that phone out side the network, which means, it only works on single SIM (MobiJoke, VodaFool) 

Mmmmm, so I don't like to be A Joke (MobiJoke) nether Fool (VodaFool) nether iDiot (Being iPhone user)
because it is not fair, simply you can get this device with same amount work any where in the world, 
please check the "Apple Hong Kong" store and see it
also here is snap from the Site




Mmm, Vodafone called me, Let us see the tons of jokes they told me.
I will tell you the bottom lines to save your time, it was 9 minutes call

"Me, The phone is too much, I have friend get it with same amount and works with any network"
this one is real, I know some one who get it from Italy and guess what it works here, guess what too, he can get to store and download "WHATEVER"
"Vodafone Guy, Hahaha, this is can't be, the government will track him and take it from him"
"Me, Why, Because of the GPS, don't u know that kids in Egypt can get n95, which has GPS"
"VF G, yes, but"
"Me, iPhone GPS has been dimmed by software methods, which means, if it cracked, it will WORK"
"VF G, but the phone can't work here in Egypt too, it will only work for the region that it sold within"
"Me, I SAW IT WORKING IN EGYPT, and the guy gets the 16 G white phone, with 4300 LE"

anyways, here is what I mean, this people are kidding, I don't know why I am thinking about reconsidering everything related to Apple.

I am sure that Apple knows, everything going on and they agree with it, 

I hope that Egyptian guys, DO NOT BUY this crap, until it gets to as promised, this always happen, Greedy resellers with greedy government 

even if it gets to the promised price I will not get it, I prefer Nokia, they have much experience in what mobile needs, not with device without "Copy and Paste"

anyways, I hope that you miss me as I miss you :)

Thanks for your time.

BR
Ahmed Essam

P.S: Sorry for the linguistic mistakes, :)

Thursday, August 21, 2008

iPhone with Arabic

Peace be upon you

how are you guys? I am very sorry for the long time not posting, but I am really so busy this days, anyways, let us head to the point.

I have got a new book for iPhone development, I have started reading some articles about it and I really like it very much, it worth the effort.

The first thing came to my mind is to show Arabic strings to the screen of the emulator, and the shock was that iPhone doesn't support Arabic, for me I started to work on the emulator and XCode until I finally did it, now I am able to show Arabic in my application on the iPhone, for me it is very important as there is a lot of development will be done on such device and of course it will need Arabic, Here is snap shoot for the emulator after writing the word ALLAH.



Thanks to ALLAH that I did, it was nice try and I learn a lot to just show this word on the emulator.

I hope that I can do something useful to my Arabian bothers and sisters, this is just a step, I will work to get deeper into the system and provide you with open source solution to support Arabic on this magnificent device.

Now I really need to sleep, thanks for reading :)

BR
Ahmed Essam