iPhone OS: Day 7, Hope
Posted by elbryan
Thank you again Ayreon
Today I made few improvements around iPhone OS. I’ve been able to query the GPS and retrieve some data from it. Actually I’m using the iPhone Simulator shipped with Xcode and I can say that it lacks in fantasy. The Simulator doesn’t provide a real “simulating” environment for GPS since it seems to provide every time the same coordinates.
Actually, I’m expected to develop a GPS-Tracking applications as my Bachelor’s Thesis, so it’s pointless using the same values for tracking a path. That’s a no go. Furthermore the things get more complicated by the fact that I don’t have an iPhone myself. Even if I had it, it wouldn’t be useful since Apple allows developers to install their own applications only if they own a special certificate released through the Apple Developer Program (that costs $99). So, yea, that’s a double no go.
Eventually I’m getting used to Interface Builder: it’s not that bad once you’ve understood how delegation things work and the secret behinds classes associations.
Another thing I’m starting to comprehend are the errors that Xcode spits out. Today I spent an hour trying to understand that an object wasn’t correctly instanced and the errors given by Xcode didn’t help me find it out.
Furthermore today I’ve learned how to “localisating” strings and how to transform objects into locale-capable objects!
Definitely a good day for my iPhone developing experience. Can’t say the same for the Apple Conference held today (where iPad has been announced) that quite disappointed me. I’d really enjoyed something more multi-tasking-ish given the new device presentation. I think this tablet won’t make the difference or echoes like iPhone did.
I’m still hopeful for the next generation SDK (the 4th edition). I really hope it will bring multi-tasking on its devices (and onto my application as well).
Posted in Apple, iPhone | no comments |
iPhone OS: Day 3, pain
Posted by elbryan
Once again, thank you Ayreon.
Today I started developing something more "special". I like the idea of having multipages since the content can be easily surfed with just two fingers. So I've started gathering information about this and I found something really interesting. An iPhone OS Developer can manage program's memory almost as much it likes. In this little application I wrote, there's a bit of memory management since just the pages nearby the current are pre-loaded. For example, if you are on page 3, only pages 2 and 4 are loaded in memory (mainly to avoid glitches when you decide to switch page).
However all that glitters ain't gold! What I'm really finding difficult to understand, is how components work. The main concept is "delegation". Everything delegates to something in a completely mystical way (at least for beginners). Sometimes you think to have full control of what you do. Sometimes you "just click into two spots" and that's it. It's quite confusing.
One thing you have to remind is the fact that delegation means "explicit delegation". Inside Interface Builder application you can put the components as you wish but you've to remember to explicitly delegate those to your previously defined interface; otherwise nothing will work. This has to be done for components as well for methods or events. It's something that you've to get used to if you want something running.
Another painful concept is nib/xib files management. These packages are something that you manage from Interface Builder but they are completely useless unless you full instance them in compile time. The first time I gave a look at Interface Builder, I started thinking that "visual objects" has to belong to "visual interface". That's not completely true. I wrote this test-application in order to understand this behaviour. The two pages that compose the applications are two distinct xib files. Once you've written them, you can put the two xibs instances into an objects array and load them on demand.
It's something like:
NSMutableArray *controllers = [[NSMutableArray alloc] init]; [controllers addObject:[[Controller alloc] initWithNibName:@"Page1" bundle:[NSBundle mainBundle]]]; [controllers addObject:[[Controller alloc] initWithNibName:@"Page2" bundle:[NSBundle mainBundle]]]; self.viewControllers = controllers; [controllers release];
In this example I create a NSMutableArray and I put inside it two instaces of two NIB files. Something that scared me firstly is that release. In the row above you just assign the value to the viewControllers variable and then you release it. I thinkg that "equals/=" means that you perform a copy of the object. Otherwise, in my code, I release something that's going to be used nextly in the program. KABOOM!! I know that's something really trivial for someone that already knows how iPhone OS works but I liked sharing that with you. Once you've done that, your array will contain two "pages". In order to pop them when you switch page, you'll have to do the opposite. Something like:
- (void) loadScrollViewWithPage:(int)page { Controller *aViewController; aViewController = [viewControllers objectAtIndex:page]; [scrollView addSubview:aViewController.view]; }
This snippet says that you have a method that does "something" whenever you change the page currently showed. Declare a Controller instance, grab from viewControllers (the NSMutableArray used above) the object at index page and then add it to the Subview. Subview is simply what you are looking at on the device (not sure if that hides something more).
Since I'm starting right now to learn programming in Obj-C / iPhone OS , I might have made some mistakes above. If you notice something weird, please let me know. Thank you.
Posted in Apple, iPhone | no comments |
Metacity loses windows position
Posted by elbryan
I finally found the end of skein! It's about 3 days that I'm googling and asking gentoo people trying to solve this annyoing problem I have. In practise, the applications that I minimize into the traybar, once restored, completely loses the postition that I gave to them.
I've so damn noticed that today when I played with Gwibber. It starts placed on the left, I place it on the right, then I minimize it into the traybar, I restore the apps after few seconds and it reappears on the left. With Compiz that didn't happen!
The solution? One frigging line command:
gconftool-2 --set -t boolean /apps/metacity/general/disable_workarounds false
It's quite funny the description of the key "Disable misfeatures that are required by old or broken applications". I think that there must be so many old and broken application nowadays..
Posted in Linux, Apps | no comments |
iPhone OS: Day 2, Isolation
Posted by elbryan
I hope Ayreon would forgive me for robbing a name from their album, The Human Equation.
These days I'm reading a lot of documentation regarding iPhone OS since I think I'm going to develop something related as part of my Bachelor's Thesis. Sincerly I'm a bit scared about this environment: being a Linux user doesn't ease my travel for sure but this device catch my attention for a lot of things. For instance I like very much the User Interface. I like how Apple designed the OS from a graphical point of view. I can easily say the same for the SDK documentation, it's really really well done. There are tons of examples, tons of documentation; there's even a mini-little tutorial for Object-C newbies.
But, well, as you may already have understood, I really dislike how the Operative System works. It's so darn closed that scares the Hell out of me. The thesis, if I'll accept it, would be an application for GPS Tracking with some other funny features like Geo Tagging, Compass usage and so on. So I've started thinking about what would ever happen if during my walk suddenly a call incomes. iPhone doesn't allow more than one application to run in foreground so the choices are only two: or you get the call, or you track your walk. 2010, dudes! I can't believe we still are forced to be tied with such things. Yea, I know. Security purposes and battery saving. Apple: spend your money on OS optimization and low-consumption hardware! (or ask Nokia how can they produce 12h devices). Well at least we can change the battery. Nope, we can't.
However, why isolation? Isolation came to my mind because of the device itself. It's completely closed. You can't install your own applications without paying a 99$ for being recognized as "Apple Developer". You can't develop an "Hello world" nowhere but Mac OS X. You cannot even try your own bloody-written application that use GPS without paying that fscking 99$. My professor told me:"Well, you still can develop some pseudo-random algorithm to feed your data analysis with". It's outside of my world, it's something I might not even conceive. After all I'm going to grit my teeth because I think that a thesis has to be as explorative as possible. I won't like the idea to put my effort in something I already know. Furthermore, iPhone has a lot of customers (with money) and a nice showcase for applications.
Don't know what will happen. I've already started buying a book. I think I'll sell it before it's shipped to my home.
Posted in Apple, iPhone | no comments |
Synchronize contacts: some advices
Posted by elbryan
How much time did you spend about digging, testing email clients?
Once you think you've found your favorite unbeatible client comes the part where you import the contacts in your address book.
Well, in my previous post I've pointed out your attention to the "formats battle" between clients. This time I just want to indicate you a Thunderbird 3 extension that I've really enjoyed so much.
Time ago, I've decided to give Google Contacts a try. It's a really simple and clean service that hosts your Address Book.
Today I've tried to make Thunderbird cooperating with Google Accounts in order to have my Address Book synced. I did it!
The extension is called Zindus. It provides a clean GUI where you should put your credentials in. That's it.
Warning: I can't remember exactly how Zindus behaved at its first launch so I strongly suggest you to backup your Address Book before "just running it" since you might lose some contact.
Posted in Linux, Apps | no comments |
Migrating Address Book from Evolution to Thunderbird
Posted by elbryan
Please, be aware of that this advice isn't strictly related to Evolution - Thunderbird migration. It's a common way to convert VCF files into LDIF/CSV.
Since I'm willing to try Thunderbird 3, I've noticed that it doesn't allow me to directly import VCF files into its address book. This is quite lame since the only format Evolution exports into is VCF and I've no luck with drag & drop and right-click menus.
Luckly I've hit a website that provides what I really need. This Online vCard Converter site performs a real-time online conversion, providing a simple and installation-free way to convert your VCF files.
Furthermore, it allows you to download the script and use it by yourself on your own machine.
Enjoy it!
Posted in Apps | no comments |
Skype, Linux, Alsa & Bluetooth
Posted by elbryan
Check out your kernel configuration. Running "lsmod" here is my module configuration related to audio/bluetooth:
lsmodModule Size Used by btusb 10883 2 rfcomm 32313 4 sco 7586 2 bnep 9474 2 l2cap 28147 16 rfcomm,bnep coretemp 4646 0 snd_pcm_oss 30288 0 snd_mixer_oss 12350 1 snd_pcm_oss snd_seq_oss 23147 0 snd_seq_midi_event 5516 1 snd_seq_oss snd_seq 43658 4 snd_seq_oss,snd_seq_midi_event snd_seq_device 5297 2 snd_seq_oss,snd_seq snd_hda_codec_realtek 256239 1 snd_hda_intel 19780 1 snd_hda_codec 61238 2 snd_hda_codec_realtek,snd_hda_intel snd_hwdep 5362 1 snd_hda_codec snd_pcm 61528 3 snd_pcm_oss,snd_hda_intel,snd_hda_codec snd_timer 16938 2 snd_seq,snd_pcm snd 51423 13 snd_pcm_oss,snd_mixer_oss,snd_seq_oss,snd_seq,snd_seq_device,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer soundcore 6040 1 snd snd_page_alloc 6813 2 snd_hda_intel,snd_pcm
Now you should gather information about your device, in particular you need its bluetooth MAC address:
hcitool scanScanning ... 00:07:B0:11:81:83 BTC5
Write somewhere this xx:xx:xx:xx:xx:xx address, you'll need it in a while.
Next step is to pair your bluetooth device with your computer. I use gnome-bluetooth to manage bluetooth devices on my system so feel free to use anything that works for your system. Look up for your device, start pairing it and issue the PIN (usually 0000 for handsets).
Once everything seems working fine, let's configure ~/.asoundrc (Notice that this file should be placed in your user homedir).
Well, open that file (or create it) with your favorite text-editor:
vi ~/.asoundrcpcm.bluetooth { type bluetooth device xx:xx:xx:xx:xx:xx # The device address gathered before }
This will tell your audio tools that exists another control named "bluetooth" that points out to the device address "xx:xx:xx:xx:xx:xx" (your bluetooth headset).
This should be enough, fire up skype and choose "bluetooth" for incoming and outcoming audio flows.
Note: Some issues you might encounter:
Please make sure you run skype from a terminal to collect more informations
- This error shows up:
ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL bluetooth
Actually you might ignore this message. However, if you followed Bluez HOWTO/AudioDevices and you put something like
in your ~/.asoundrc, then I can tell you that I had this issue before. I just removed this "workaround" and I simply used the "normal" configuration.pcm.bluetoothraw { type bluetooth device 00:11:22:33:44:55 } pcm.bluetooth { type plug slave { pcm bluetoothraw } } - On Gentoo amd64 is possible that you get some errors regarding not found lib32 libs. This is "normal" (shouldn't be, but happens). Just unmask and use app-emulation/emul-linux-x86-soundlibs-20091231. This ebuild contains lib32 alsa-bluetooth libraries you need.
Posted in Audio, Linux | 2 comments |