Sep 18, 2011
salemsayed

How to get OpenCV working under Mac OS X Lion with XCode 4.1

Throughout this year’s Computer Vision class, we are asked to use OpenCV for the practical part of the course. As it’s very easy to get it running on Windows with Visual Studio, i will only focus on how to get it working on Mac OS X Lion with XCode 4.1

1- Download and install OpenCV

In order to do that, there is the easy way,  and the geeky way. The easy way is to just download MacPorts (available for Snow Leopard and Lion) and let it download and install OpenCV and all of it’s dependencies. Or to checkout the latest SVN snapshot and build from source using CMake as instructed here and here. In this tutorial i will follow the easy way (MacPorts). So, grab the appropriate package of MacPorts for your system and install it (it may take a while at the end of the installation, don’t worry that’s perfectly normal). After your done, open Terminal.app and type the following command

sudo port install opencv 

If you already had MacPorts installed, make sure you run the following commands to update MacPorts itself and the currently installed packages before attempting to install OpenCV

sudo port selfupdate

sudo port upgrade outdated

Go grab a coffee or (a novel as suggested by @Abo_Shanab)  as this will take a while. After it’s done you should know that OpenCV is now to be found at /opt/local/

2- Configure XCode 4.1

Incase you don’t have XCode 4.1, you can easily get it from the Mac App Store for free . Now, open XCode and make a new project and choose “Command Line Tool”, give the project any name you’d like (OpenCV-Test for an example) and choose C++ as the type of the project.  Click on the project name in the left drawer, click on the name of the project under the label “Targets” and click on “All” in the project settings to choose all configurations.

Use the search tool to find “Header search path” and add to it /opt/local/include and “Done”. Right click on the project name in the left drawer and choose “New Group” name it for an example “OpenCV-Frameworks”. Right click the newly created group and choose “Add Files To “OpenCV-Frameworks”…” type “/” to trigger the Go To Folder modal window and paste the following path: /opt/local/lib and include libopencv_ml.2.2.0.dylib, libopencv_highgui.2.2.0.dylib, libopencv_core.2.2.0.dylib. Uncheck “Copy Items …” and click Add.

Open the main.cpp and paste the following code snippet to test things out.

#include <iostream>

#include <opencv2/opencv.hpp>

int main (int argc, const char * argv[])

{

/* create an image */

IplImage *img = cvCreateImage(cvSize(200, 100), IPL_DEPTH_8U, 3);

/* draw a green line */

cvLine(img,                         /* the dest image */

cvPoint(10, 10),             /* start point */

cvPoint(150, 80),            /* end point */

cvScalar(0, 255, 0, 0),      /* the color; green */

1, 8, 0);                    /* thickness, line type, shift */

/* draw a blue box */

cvRectangle(img,                    /* the dest image */

cvPoint(20, 15),        /* top left point */

cvPoint(100, 70),       /* bottom right point */

cvScalar(255, 0, 0, 0), /* the color; blue */

1, 8, 0);               /* thickness, line type, shift */

/* draw a red circle */

cvCircle(img,                       /* the dest image */

cvPoint(110, 60), 35,      /* center point and radius */

cvScalar(0, 0, 255, 0),    /* the color; red */

1, 8, 0);                  /* thickness, line type, shift */

/* display the image */

cvNamedWindow("img", CV_WINDOW_AUTOSIZE);

cvShowImage("img", img);

cvWaitKey(0);

cvDestroyWindow("img");

cvReleaseImage(&img);

return 0;

}

Build and Run (Command+R) and you should see the following box

Voila !

Notes:

1- You may find 3 warnings, those warnings are in the core files of OpenCV, so you can just ignore them.

2- Using 

#include <opencv2/opencv.hpp>

will include the rest of the OpenCV header files.

3- When using an on-disk image, using the absolute path is recommended as i couldn’t find a way to make it work with project relative path.

Update: This tutorial has been suggested by Hossam Amer to get OpenCV working on Snow Leopard

Jul 23, 2011
salemsayed

My Graduation Project

So, yeah i finished my graduation project (FINALLY!). Unfortunately, I’m not yet graduated as the graduation project is done one year before the actual graduation (German accreditation stuff). Anyway, my bachelor project was done under the supervision of Dr. Fatma Meawad (@fmeawad). The project was titled: “Personal Trainer With Gesture Recognition Using The Kinect”. Working with Dr. Fatma was (as always) a bliss. However, working with the Kinect with the limited resources, was painful. But, looking back at the whole experience, i think i really enjoyed the whole semester and the project.

Anyway, here is the abstract of the project to know more about the idea and the motivation behind the project.

Working out is the hope of many, if not everyone. However, we are always faced with the hassle of finding a gym, a trainer, and a parking spot. Etc. Personal Trainer hopes to solve this problem and provides the users with a way to work out with the ease and comfort of being at home and with the precision and feedback of a visual trainer. The aim of this project is to provide the player with an accurate feedback for their training as well as regular periodic inspection that can be expected from a personal trainer. This is done using different modules communicating with each other to provide the player with an enjoy-full experience. In order to do that the Microsoft Kinect is used. Its capabilities in tracking and generating skeleton information is the basis on which this project was developed.

This thesis will discuss how a system like this can be implemented. It will discuss all the different technologies available that could help. It will also offer an in-depth look of different approaches and methodologies used when solving problems such as gesture recognition and body measurements. The system’s goal is to provide the user with the whole personal trainer experience, at home. That experience is mainly split into modules, the feedback and the timely inspection. This thesis will explain thoroughly how each of them (and other modules) where implemented. This project aims to increase the number of individuals playing sports and working out on a daily basis, which will in turn benefit them with better health.

The results of the evaluations have shown that the majority of players coming from different backgrounds really liked the idea and wanted to use it daily. The Kinect and the hands-free experience that it provides fascinated them. They were also interested to know more about it and about the different games already supporting it. It was clear that the testers that were more willing to buy the Kinect and get the game, were the ones that are actually not willing to go to an actual gym. However, the testers were not impressed by the program’s accuracy and error rate. They had also provided some valuable comments and suggestions that can help transition this project from a proof of concept to an actual commercial game.

If you like to know more about the project, you can go ahead and check my thesis where you will find every piece of information related to the project. It can be browsed online here. Also, my defense and presentation can found here.

Oh, and i got an A+ (el7amdullah) :D

Mar 14, 2011
salemsayed

How to: Jailbreak iPod Touch 2G MC 4.2.1

Let’s face it, if you own an MC model, then you’ve always been stuck waiting for a decent jailbreaking solution and there is always some problems accompanying it. I just spent a couple of hours trying to jailbreak my MC model ipt2g and i faced 2 main problems that took me a lot of time to find their solutions. Anyway, here it goes:

1- Restore using 4.2.1, a clean update is always the best

2- Assuming the ‘greenpois0n.app’ is on the desktop, open a terminal session and type the following


cd Desktop

open greenpois0n.app/Contents/MacOS/greenpois0n

this was to avoid getting the “failed” error

3- greenpois0n will launch and follow the on-screen instructions

4- Now, you should find a Loader.app with a green icon, DON”T OPEN IT ! reboot the device

5- Go to Settings -> General -> Auto-Lock to ‘Never’

6- Reboot the device

7- Go to Settings -> Wi-Fi -> Setup your WiFi

8- Reboot the device (yes, you have to do that)

9- Open the loader, install Cydia, it will continue till 50% and it will then start extracting and it will install just fine (hopefully!)

Source: here

Note: Those steps were done on a Mac OS X 10.6.6, i can’t guarantee the success of it on another platforms.

Dec 21, 2010
salemsayed

How to: Compile and use primegen library

During my Microprocessors course, we were asked to implement the algorithm of Sieve of Eratosthenes which generates all prime numbers starting from 2 till n. We were asked to implement it using CUDA and during our development and testing we used a library called ‘primegen‘ for the sake of debugging our output, which does the same using a faster algorithm which is Sieve of Atkin. Those instructions will work on any *nix (Ubuntu, Mac OS X .. etc).

1- Download the package from primegen‘s website.

2- Extract and browse by the terminal to the extracted files

3- Issue the following command in the terminal


sudo make

sudo make setup check

4- Now, it’s compiled and you should execute it by the following command


./primes 1 30

This will generate and print out to terminal the prime numbers found from 1 till 30, you could also use the following


./primes 1 30 | wc -l

which will get you the number of primes instead of the primes themselves. wc is word count and it takes -l as a flag to print only the number of lines.

Oct 15, 2010
salemsayed

How to: Develop for GLUT using XCode on Mac OS X

I’ve linked to a tutorial in my last post that details the whole process of getting GLUT and OpenGL working in XCode. However, i’ve found out an easier way to achieve the same result and without useless frameworks. Here it goes.

  • You need to install XCode either through the application DVD came with your Mac or, by signing up for a free Apple Developer account from here.
  • Open up XCode, choose create a new project.

  • From the left column under Mac OS X, choose Application. from the right pane choose “Command Line Tool”.

  • I will give the project the name “HelloGlut”, hit Save and wait for the main window to appear.
  • Right click on the project name, in this case “HelloGlut”, then Add, then Existing Frameworks.

  • A list of frameworks available will be shown, choose GLUT, repeat the same step to choose OpenGL, or select both by holding the Ctrl button.

NOTE: To use GLUT/OpenGL API you should include their header files in the following way


#include <GLUT/glut.h>

#include <OpenGL/gl.h>

And, if you want to include any other .h files you should prefix them GLUT/ or OpenGL/ as shown above.

To demonstrate and test our steps, open the main.cpp, remove the sample code generated by our project creation process and paste the following

#include <GLUT/glut.h>
#include <OpenGL/gl.h>

void myInit(void)
{
	glClearColor(1.0,1.0,1.0,0.0); // set white background color
	glColor3f(0.0f, 0.0f, 0.0f); // set the drawing color
	glPointSize(4.0); // a ‘dot’ is 4 by 4 pixels
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}
void myDisplay(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the screen

	//First Line
	glLineWidth(8.0f);

	glBegin(GL_LINE_STRIP);
	glColor3ub(255, 0, 0);
	glVertex2i(40, 380);
	glColor3ub(0, 255, 0);
	glVertex2i(600, 380);

	glEnd();

	//Second Line
	glLineWidth(8.0f);

	glBegin(GL_LINE_STRIP);
	glColor3ub(0, 0, 255);
	glVertex2i(40, 250);
	glColor3ub(0, 255, 0);
	glVertex2i(600, 250);

	glEnd();

	//Third Line
	glLineWidth(8.0f);

	glBegin(GL_LINE_STRIP);
	glColor3ub(255, 0, 0);
	glVertex2i(40, 120);
	glColor3ub(0, 0, 255);
	glVertex2i(600, 120);

	glEnd();

	glFlush(); // send all output to display
}

int main(int argc, char** argv)
{
    //GLUT & OpenGL
	glutInit(&argc, argv); // initialize the toolkit
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
	glutInitWindowSize(640,480); // set window size
	glutInitWindowPosition(100, 150); // set window position on	screen
	glutCreateWindow("my first attempt"); // open the screen window
	glutDisplayFunc(myDisplay); // register redraw function
	myInit();
	glutMainLoop(); // go into a perpetual loop

}

Choose ‘Build & Run’ from the ‘Build’ menu and, you should be greeted with the following

I also recommend checking out this question on StackOverflow, it has a lot of beneficial shortcuts and tips to help you speed up your productivity using XCode.

This has been tested on XCode 3.2.2 and Mac OS X 10.6.4

Sep 28, 2010
salemsayed

How to: Install GLUT in Ubuntu 10.04 and Mac OS X 10.6

If your looking for Mac OS X, check here

This tutorial will guide you through the installation of GLUT on Ubuntu 10.04 and Mac OS X [See Note1]. So, GLUT as you may know is a wrapper for OpenGL which will provide you with some sort of abstraction from OpenGL OS specific API and helps you develop portable code between platforms. However, GLUT’s latest version (3.7) dates back to August 1998 and as you may expect, another project emerged (freeglut) which provides 100% replacement for the original GLUT code. So, we will be using that while developing in Ubuntu.

First, make sure you have the gcc compiler installed


sudo apt-get install g++

Next, install the required packages by the following command


sudo apt-get install freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev mesa-common-dev

… and your done!

Just make sure that you #include <GL/freeglut.h> in your .cpp files. To compile, use the following terminal command


g++ -lglut -lGL -lGLU -lGLEW helloworld.cpp

the flags are just linkers to libraries that you may need, “helloworld” is the name of the file containing the source code. If the compile is successful, you will find a new executable in the same folder as the .cpp file with the same name, double click, it will run *hopefully*.

Note1: While i was trying to get it work i had the following error


helloworld.cpp:1:27: error:  GL/freeglut.h : No such file or directory

turns out i used that


#include < GL/freeglut.h >

instead of that


#include <GL/freeglut.h>

If you faced any problems in any of the two ways, please let me know in the comments :)

Aug 21, 2010
salemsayed

Getting started with iPhone API for SmartFoxServer

In this tutorial i hope i can guide through working with SmartFoxServer using the iPhone API. We will try to do the base of a simple chat application that can connect to our server and retrieve the list of rooms, It’s pretty basic but, it will provide as a starting point for a lot of possible applications. Our chat application will need a server to handle the communication between clients, so, for that we will be using SmartFoxServer Pro. SmartFoxServer is intended to be used in Multiplayer games and chat applications, it will provide us will a lot of options such as: Room moderations, ban list, ip ban and other. But, most importantly it will provide us with iPhone API which we will use to communicate between the client (iPhone app.) and the server (SmartFoxServer). The reason we are using the Pro version is that it’s the only version that supports the iPhone API, While it’s free to use, it’s limited to only 20 concurrent connections, which i think will be more than enough for the sake of our tutorial. SmartFoxServer is available for Windows, Linux and Mac OS X, through the tutorial i will be using the Mac version, but, there should be no major difference between it and other versions. Also, most of our work will be on the client side.

So, let’s get started by downloading SmartFoxServer Pro from here. Extract the downloaded file (SFSPRO_166_macosx.dmg.zip) , open the DMG (SFSPRO_166_macosx.dmg) copy it to Applications folder.

Note: If your using Windows Vista/7

Installing SmartFoxServer under the C:\Program Files\ path will not allow you to modify the configuration and example files, as Windows requires administrator privileges to modify any file under that path.

If you intend to open and edit the example files you will have to move them to a directory under your home folder to avoid problems with write privileges.

Our suggestion is to install the whole SmartFoxServer package under your home folder to avoid any of the aforementioned issues.

Browse to the Applications folder, open ‘SmartFoxServer PRO 1.6.6′ and double click on ‘SmartFoxServer’. This should open a nice popup windows where the server initialize itself, It’s worth mentioning that the popup won’t go away when the server is running, so, if you see the text ‘Server is up and running!’ then everything went fine and the server is fine!

You can browse to ‘http://localhost:8080/’ to check the server landing page, which isn’t useful to us now, but, it’s a way to make sure that everything is fine. Anyway, what we really care about is the Admin tool, so, browse to the folder where you’ve installed/copied SmartFoxServer, there should be folder called ‘Admin’ where an ‘AdminTool.swf’ should exist. Open it using your browser.

You should be greeted by the window shown above where you should enter your login credentials to your server, in our case, we will leave the 127.0.0.1 and the port intact as we are running our server on our machine (localhost) and with the default port. The username and password are:
sfs_admin
sfs_pass
Press on ‘Submit’ and everything should be fine *hopefully*

There is a lot of options and a lot of things to discover by reading the documentation but, am only interested in one thing which is the Zone Browser. A Zone is an entity by itself, you can think of it as a separate game, our server can handle more than one game at a time, that’s why we have more than one Zone. In each Zone we can have as many rooms as we wish, think of the rooms as an instance of the game (The Zone). So, in our case the game is a chat application and each room is a chat room in it’s own. As i don’t want to get into much details regarding the server side, we won’t create a new zone or room, however, we will use a zone provided by default into the server which is ‘simpleChat’ that consists of 5 rooms + lobby room which is auto joined when you join the zone. You can take a look and edit a lot of the Zone settings by clicking on ‘Zone Browser’ then browse till you fine ‘simpleChat’.
That’s it for the server, we won’t customize anything else, we just need it to be running and shift our attention to the client side and the provided API.

So, our app should consist of two views, 1 for the login to the server, and the other for sending and receiving messages from other clients connected to the same Zone, but, for the sake of simplicity we will only implement the login view and retrieve the room names through the terminal.

You should create a view based application, as it will provide us with a controller linked to a view that loads on application start. Then you should download the iPhone API from here , after that, you should follow this excellent tutorial on how to import the API into your project. If you’ve followed the tutorial correctly, your empty project should Build correctly with no errors or warnings.

So, first construct the view in the interface builder as shown, link it to the outlets

and change the orientation to be Landscape by adding this method to your controller .m file.


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

// Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

}

Also, make sure your view controller .h file conform the the UITextFieldDelegate protocol as we will need to customize the UITextField. If you build and run you will notice two problems with our view.

  1. The soft keyboard hides the view when it’s triggered
  2. The soft keyboard won’t go away when pressing ‘return’

Those problems are common and you can easily fix them by adding the following methods to your view controller’s .m file

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	[textField resignFirstResponder];
	return YES;
}

- (IBAction)onEditingDidBegin:(id)sender
{
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationDuration:0.3];
	CGAffineTransform transform = CGAffineTransformConcat([[self view] transform], CGAffineTransformMakeTranslation(100, 0));
	[[self view] setTransform:transform];
	[UIView commitAnimations];
}

- (IBAction)onEditingDidEnd:(id)sender
{
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationDuration:0.3];
	CGAffineTransform transform = CGAffineTransformConcat([[self view] transform], CGAffineTransformMakeTranslation(-100, 0));
	[[self view] setTransform:transform];
	[UIView commitAnimations];
}

NWe will then connect the two IBAction methods to our UITextField as shown

Now, we should start the connection itself with the server, so, open the app. delegate and add the imports to the .h file


#import "INFSmartFoxISFSEvents.h"
#import "INFSmartFoxSFSEvent.h"
@class INFSmartFoxiPhoneClient;

Also, make sure you conform to the ‘INFSmartFoxISFSEvents’ protocol, and, finally add the following ivar


INFSmartFoxiPhoneClient *smartFox;

Which will our connection to the server, something like the connection string if you’ve used Java or ASP before. In our app. delegate .m file we should import the following:


#import "INFSmartFoxiPhoneClient.h"

#import "INFSmartFoxObjectSerializer.h"
<pre>#import "INFSmartFoxRoom.h"</pre>

Ok, what we’ve done so far is, construct a view with our components and handle the imports for the server connection in our app. delegate. What is left is the connection itself which is handled in the app. delegate as we will see. We first need an xml file that will have the path to the server. Right click on resources, Add >> New File >> Other >> Empty File name it config.xml, and paste the following:


<SmartFoxTrisConfig>

<ip>localhost</ip>

<port>9339</port>

<blueBoxIpAddress>localhost</blueBoxIpAddress>

<blueBoxPort>8080</blueBoxPort>

<smartConnect>true</smartConnect>

<httpPort>8080</httpPort>

<httpPollSpeed>750</httpPollSpeed>

<zone>InfosferiPhoneOkeyServer</zone>

</SmartFoxTrisConfig>

Back to the app. delegate .m file  we should init. the connection to the server in the ‘didFinishLaunchingWithOptions’ method. The string “config” is the name of the config.xml file we’ve just created.


//Smartfox init.

[INFSmartFoxObjectSerializer setDebug:YES];

smartFox = [[INFSmartFoxiPhoneClient iPhoneClient:YES delegate:self] retain];

//config is the name of the XML config file

[smartFox loadConfig:@"config" autoConnect:YES];

we should also add the following three methods

- (void)onConnection:(INFSmartFoxSFSEvent *)evt {
	//Enable the login button and the textfield
	if ([[evt.params objectForKey:@"success"] boolValue]) {
		view.connectLabel.text = @"Connected, please login";
		view.loginButton.enabled = YES;
		view.loginTextField.enabled = YES;
	}
	else {
		view.connectLabel.text = [NSString stringWithFormat:@"Connection error: %@", [evt.params objectForKey:@"error"]];
	}
}

- (void)onConnectionLost:(INFSmartFoxSFSEvent *)evt
{
	NSLog(@"onConnectionLost");

    //Disable textfield and button until connected!
	view.loginTextField.enabled = NO;
	view.loginButton.enabled = NO;

    //Retry connection
	[smartFox loadConfig:@"config" autoConnect:YES];
}

-(void)login:(NSString *)loginName {
	[smartFox login:@"simpleChat" name:loginName pass:@""];
}

the onConnectionLost and onConnection methods are part of the ‘INFSmartFoxISFSEvents’ protocol, they are called when the connection is successful and on failure. The login method is where the login procedure itself is done, and as you can see the NSString “simpleChat” is the name of the Zone we said we will be using.

Back to our view controller .m file we should the following method, and connect it to the UIButton so that it triggers the connection.


- (IBAction)buttonPressed:(id)sender {

[[[UIApplication sharedApplication] delegate] login:loginTextField.text];

}

Now, Build and Run, after you login the console should output the names of the rooms.

I hope everything was clear and everything went fine, however, here is the XCode project with the source code for reference. Download Also, in the iPhone API you’ve downloaded, you will find a tutorials folder which have 2 excellent tutorial that i think you should check.

If you still have any questions/suggestions, please share them in the comments :)

Aug 8, 2010
salemsayed

Introduction to iPhone development

On 1.8.2010 i gave a lecture titled “introduction to iPhone development” This lecture was part of my requirements during the g-osc internship period. The purpose of the lecture was to introduce people to iPhone development and state what is required from them to get started and of,course show how easy it is to get started in that field.

As with all the talks given during the g-osc technology camp, it was recorded and now you can watch it here (apologies for the quality). Also, the slides are available here.

So, if you’ve watched the videos or you did attend the lecture, I’d like to get feedback on my performance and the lecture’s content, whether you liked it or not, what can i improve as a presenter, what should have been said, everything! Am sure i can learn something from your criticism. Also, we can use this post to discuss anything you may not have understood or any fear you may have from starting iPhone development.

Aug 8, 2010
salemsayed

How to: Edit a contact’s phone number

During my internship @ the g-osc technology camp, i was trying to build an iPhone app. that manipulates the address book. The application purpose was to find all phone numbers with a special prefix and change that number to something else while preserving all other data of the contact. So, i went over to Apple’s documentation of how to use the iPhone’s address book (ABAdressBook) which includes length description with sample applications and everything … Except, editing a contact’s property (phone number, address .. etc). It only contained information on adding a new record and deleting an old record.

What i tried to do is mix things up by getting all properties of a contact’s and editing whatever i wish then, I’d create a new contact and assign those properties to that new contact and of,course delete the old one. As you might expect this has failed and it was kinda stupid. So, i sat down, read the documentation once more and i managed to get it right from the first time by just

  • Getting a record
  • Getting it’s phone numbers multi-valued property
  • Making a mutable copy of phone numbers, changing whatever i wanted
  • Replacing the phone number property with the mutable (changed) phone number list

Anyway, Here is the code


       //Connect to iPhone's address book
	ABAddressBookRef addressBook = ABAddressBookCreate();

	//An array of all contacts
	NSArray *allPeople = [[NSArray alloc] init];
	allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

	//Number of contacts
	NSInteger peopleCount = [allPeople count];

	//New phone number
	NSString *changedNumber = [[NSString alloc] initWithFormat:@"0100000011"];

	//Loop on all records
	for (int i= 0; i < peopleCount; i++) {

		//Get record
		ABRecordRef record = [allPeople objectAtIndex:i];

		//Get phone numbers
		ABMultiValueRef multiPhones = ABRecordCopyValue(record,
                kABPersonPhoneProperty);

		//Create mutable list to be able to modify numbers
		ABMutableMultiValueRef multiPhonesList =
                ABMultiValueCreateMutableCopy(multiPhones);

		//Number of phone numbers
		NSInteger count = (NSInteger)ABMultiValueGetCount(multiPhones);
		for (int j = 0; j < count; j++) {

			//Replace old number with new number
			BOOL replace = ABMultiValueReplaceValueAtIndex
                                              (multiPhonesList,changedNumber,j);
			if (!replace) {
				NSLog(@"Error Replacing");
			}

			//Replace old multivalue with new multivalue
			BOOL setValue = ABRecordSetValue(record,
                        kABPersonPhoneProperty,multiPhonesList, nil);
			if (!setValue) {
				NSLog(@"Error setting value");
			}

		}

	}
	//Save addressbook
	BOOL save = ABAddressBookSave(addressBook, nil);
	if (!save) {
		NSLog(@"Save error");
	}

Now, your address book contacts phone number’s will all be changed to: 0100000011.

Jul 21, 2010
salemsayed

To Classify or not to classify, that’s the question!

During g-osc summer camp we (technology explorers) are required to do documentation on every thing we find/use in order to learn the new technology we are assigned to, this documentation will server as a page or a document to others whom will be going through our same path in learning the same technology. The problem we are currently facing is the way of organizing this data into the g-osc media wiki page.

During my discussion with Dr.Fmeawad, two ideas came up on how to organize this data in a simple way to make it easy for beginners to learn as well as being beneficial to people with established knowledge in that field.

First idea was to make it as a regular wiki page, something similar to the any page you will find on Wikipedia, classifying everything and putting every resource or tip under a section/subsection. The problem with that solution is that it’s hard to classify and even if we classify, after some time learning there is a great chance that this classification will keep on changing and maybe never reach a steady state. The advantage of this method is that everything is laid out in a way the reader is already adapted to from reading articles on Wikipedia, a way that will guide the novice user to where to look for information and in the same time caters for readers with various levels of background knowledge of that subject by providing a classified page with a table of contents where they can hop in and gather the information they need.

The other proposed solution was to put every piece of information as a separate item with the technology explorer’s comment on it, a comment that will give a glimpse of what this resource will provide. Also, each item will be tagged in order to produce a tag cloud that will help the learner filter the items based on a specified tag. However, i think this will result in a long page filled with items with no classification but only tags which can’t be very accurate while your searching for a specific thing, which may result in spending longer time searching and filtering the already filtered list of items! On the other hand, this method will be easier for any contributor to just hop in, add an item with a comment and they are done! no need to skim through a long page of information to see where to plug-in the information.

You can check the iPhone development g-osc wiki page here where you can check both options implemented for the sake of demonstration.

I personally dislike both options and i think there might be a third option or maybe a hybrid of both options! but, i can’t really figure it out. So, the question now is, if your learning a new technology and have only one page to gather information from, what would be the best thing for you?

Pages:12»
Stop SOPA