Κυριακή, 26 Μαΐου 2013

ios Xcode4 - Core Data: How to enable SQL Debuggin

source stackoverflow

You should be looking at the same place you get NSLOGS
And you should Go to Product -> Edit Scheme -> Then from the left panel select Run YOURAPP.app and go to the main panel's Arguments Tab.
There you can add an Argument Passed On Launch.
You should add -com.apple.CoreData.SQLDebug 1
Press OK and your are all set.
The key here is to edit the scheme you will be using for testing

Σάββατο, 25 Μαΐου 2013

Preparing my first apple store application for upload - Upload my first application


Fast notes:)

  • Use the build for testing to see possible trunk code you left behind!
  • Ensure that you applications is not memory leaking
    • run Product - Profile - Leaking to check your application for possible memory leaks
  • To protect your app from being compromised by a hacker who might damage the user’s system, you give permissions, known as entitlements, to your app to perform specific functions. An entitlement is a key-value pair whose value you can set to specify a capability or security permission. This chapter describes entitlements you configure in your Xcode project for certain technologies supported by the store. Refer to Entitlement Key Reference for a complete list of app entitlements.
    To enable entitlements
    1. In Xcode, select the target in the project editor.
    2. Select the Summary tab and scroll down to the Entitlements section.
  • create InfoPlist.string to change the name of the application shown below the app icon.
    • "CFBundleDisplayName" = "dfasdf";
    • "CFBundleName" = "assfasdfasfd";
  • splash screens with localizations
  • Make a Provisioning Profile that is for Developer
    • click Certificates - create new (one for distribution). You will need to follow the instrunctions (create a keypair from keychain etc). When you finish a new Distribution Certificate must be valid. Download it and install it on your xCode or refresh the provisioning at xCode to auto-download it. 
    • On identifiers probably you have allready an IDs. A Name-ID pair example name: Learn and ID * means that with the identifiers Learn you can develop every named application you want. The applications don't have in real names but have bundles IDs. If you want the identifiers ID to be specific to only one application that you are developing then write in reverse the SAME bundle you have on your application.
    • On project make the Bundle identifier the same with the ID identifier!
  • Build your project with distribution sign
    • Select the project.
    • Click Build Settings.
    • Click All.
    • Type Code Signing in the search field in the Build Settings pane of the project editor.
    • From the Code Signing Identity pop-up menu, in the iOS Team Provisioning Profile section, choose the certificate that begins with “iPhone Developer:” followed by your name.
  • making the binary 
    • Find the file ending in ".app" in the Products folder of your application in Xcode. Right-click on it and choose Show In Finder. From there, right-click again and choose Compress.
      The resulting zipped file is the binary of your iphone application.
  • iTune Connect: manage your applications (lang - localizations  - see downloads - pricing etc).
    • you will need to have the proper icons 
    • create 512x512 and 1024 x1024 icons for shopt with names iTunesArtwork.png and iTunesArtwork@2x.png
    • take screenshots screenshots
  • create a new application at iTune Connect: (select the default lang - same with as your project is set). You will localize the all files later. 
  • After you take name and other staffs you have the yellow light (ready to upload)Some times you need first press the view Details below and click on be ready to upload to be really ready. 
  • use the Application Loader to upload the binary you made above. If no problem exist your application will be upload. 
  • Localizing the other data inside the  iTuneConnect  (click View Details on the app)
 “Localizing Metadata, Keywords, and Screenshots


Cross you fingers and i'm sure that soon apple you will aprove your app.


good luck



Last edit 26/5/2013

Τετάρτη, 15 Μαΐου 2013

LOCALIZATION - an ios application

apple instructions here

Below is instrunctions from the book The Big Nerd Ranch Guide (3rd Edition)


Internationalization Using NSLocale:

NSString * currencySymbol = [[NSLocale currentLocale] objectForKey: NSLocaleCurrencySymbol];
[ aLabel setText: [NSString stringWithFormat:@"%@", currencySymbol]];

Localizing Resources: 

  • These resources are organized into language-specific directories, known as lproj directories
  • add a language in the project setting first!
  • Click on an .xib file
  • open the file inspector
  • find the section Localization and click the + button at the bottom.  (this creates an lang.lproj folder and adds a copy of aaa.xib to it. 
  • Tsanslate localized files yourself!
  • Instead! you can use a command-line tool named ibtool to get the strings from your native language XIB file into a file. Then, you can trasnlate thses strings and create a new XIB file for each language. 
    • open terminal.app (Applications/Uitilites)
    • cd (Drag the en.lproj folder's icon from the Finder onto the Terminal window)
    • cd /iphone/myappication/application/en.lproj
    • ibtool --export-strings-file ~/Desktop/MyViewController.strings MyViewController.xib (this will create a DetailViewController.strings files on your desktop that contains all of the strings in your XIB file. 
    • open the file , transalate the texts to greek version. Save this new greek file. 
    • In terminal enter: ibtool --import-strings-file ~/Desktop/MyViewController.strings --write
    • ibtool --import-strings-file ~/Desktop/MyViewController.strings --write /iphone/myappication/application/gr.lproj/MyViewControoler.xib /iphone/myappication/application/en.lproj/MyViewControoler.xib
    • This command says Create MyViewController.xib in gr.lproj from MyViewController.xib in en.lproj, and then replace all of the strings with the values from MyViewController.strings.
    • Ingore the warnings from ibtools about GSCapabilities. 
    • Open the MyViewController.xib (greek) in Xcode. This XIB file is now localized to Greek. 

To test DELETE the application from your device or simulator. Then choose Clean, Build.
Change the language settings on the device (example to Greece) to see the effect. 

NSLocalizedString and Strings Tables
Fast review: 

  • Replace the strings you want to be transalate with NSString *translatedString = NSLocalizedString (@"Hello!", @"The greeting for the user");
  • At terminal run genstrings MyViewController.m to extract the above strings
  • with mouse put the Localizable.strings into your project
  • Localize from file inspector teh Localizable.strings. Add you langs also. 
  • click on lang version of Localizable.string you prefer and change the strings after the = into your lang.
  • clean - build - fun. 
Analytical:
For dynamically created NSStrings instances you must create a strings table. A strings table is a file containing a list of key-value pairs for all of the strings that your application uses and their associated translations. It's a resource file that you add to your application,.
Whenever you have a string in your code like @"My text", to internationalize this, replace literal strings with the function NSLocalizedString
NSString *translatedString = NSLocalizedString (@"Hello!", @"The greeting for the user");

Once you have a file that has been internationalized with the NSLocalizedString function,  you can generate strings tables with a command-line application. 
Open Terminal.app and navigate to the location of MyViewController.m The command will look like this: 
  • cd /iphone/Myapplication/Myapplication/
  • genstrings MyViewController.m
This creates a file named Localizable.strings in the same directory as MyViewController.m Drag this file into the project navigator. When the application is compiled, this resource will be copied into the  main bundle. 

Open the Localizable.strings file inn the editor area (reinterpet in Unicode (UTF-16)-utilitie-file inspector Text Settings - Text Encoding - Unicode )) if any problem. 
Now localize ti like the above XIB file in the first section of this post. Select the file in the project navigator an dclick the plus button in the utilities area. Add the Greek localization and then open the Greek version of Localizable.strings.  The string on the lefthand side is the key that is  passed to the NSLocalizedString function and the string on the righthand side is what is returned. Change the text as you want. 

build and run.  (better first delete the application, clean your project and rebuild. 

Κυριακή, 12 Μαΐου 2013

how to use uisegment control


 source here:

- (IBAction)segmentSwitch:(id)sender {
  UISegmentedControl *segmentedControl = (UISegmentedControl *) sender;
  NSInteger selectedSegment = segmentedControl.selectedSegmentIndex;

  if (selectedSegment == 0) {
    //toggle the correct view to be visible
    [firstView setHidden:NO];
    [secondView setHidden:YES];
  }
  else{
    //toggle the correct view to be visible
    [firstView setHidden:YES];
    [secondView setHidden:NO];
  }
}

Transform UIImage into Black'n'White image



source here:


- (UIImage *)getBlackAndWhiteVersionOfImage:(UIImage *)anImage {
 UIImage *newImage;
 
 if (anImage) {
  CGColorSpaceRef colorSapce = CGColorSpaceCreateDeviceGray();
  CGContextRef context = CGBitmapContextCreate(nil, anImage.size.width * anImage.scale, anImage.size.height * anImage.scale, 8, anImage.size.width * anImage.scale, colorSapce, kCGImageAlphaNone);
  CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
  CGContextSetShouldAntialias(context, NO);
  CGContextDrawImage(context, CGRectMake(0, 0, anImage.size.width, anImage.size.height), [anImage CGImage]);
  
  CGImageRef bwImage = CGBitmapContextCreateImage(context);
  CGContextRelease(context);
  CGColorSpaceRelease(colorSapce);
  
  UIImage *resultImage = [UIImage imageWithCGImage:bwImage];
  CGImageRelease(bwImage);
  
  UIGraphicsBeginImageContextWithOptions(anImage.size, NO, anImage.scale);
  [resultImage drawInRect:CGRectMake(0.0, 0.0, anImage.size.width, anImage.size.height)];
  newImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
 }
 
 return newImage;
}

uiimage compress


- (UIImage*)imageWithImage:(UIImage*)image
              scaledToSize:(CGSize)newSize;
{
    UIGraphicsBeginImageContext( newSize );
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return newImage;
}


CGRect rect = CGRectMake(0.0, 0.0, 480, 720);
image = [self imageWithImage:image scaledToSize:rect.size];


480x720 are printable and near to 0.8MB

how to zoom a uiimage


  1. create a UIScrollView, set delegate of here
  2. put the UIImage inside the UIScrollView
  3. at .h file conform the UIScrollViewDelegate
  4. at .m file
  1. - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
    {
        return self.imageView;
    }



Basic Zooming Using the Pinch Gestures

UIScrollView makes supporting the pinch gestures for zooming easy. Your application specifies the zoom factors (that is how much bigger or smaller you can make the content) and you implement a single delegate method. Taking those few steps allows your scroll view to support the pinch gestures for zooming.

Supporting the Pinch Zoom Gestures

The pinch-in and pinch-out zoom gestures are standard gestures that iOS application users expect to use when zooming in and out. Figure 3-1 shows examples of the pinch gestures.
Figure 3-1  The standard pinch-in and pinch-out gestures
To support zooming, you must set a delegate for your scroll view. The delegate object must conform to the UIScrollViewDelegate protocol. In many cases, the delegate will be the scroll view’s controller class. That delegate class must implement the viewForZoomingInScrollView: method and return the view to zoom. The implementation of the delegate method shown below returns the value of the controller’s imageView property, which is an instance of UIImageView. This specifies that the imageView property will be zoomed in response to zoom gestures, as well as any programmatic zooming.
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.imageView;
}
To specify the amount the user can zoom, you set the values of the minimumZoomScale and maximumZoomScale properties, both of which are initially set to 1.0. The value of these properties can be set in Interface Builder’s UIScrollView inspector panel, or programmatically. Listing 3-1 shows the code required in a subclass of UIVie

Σάββατο, 11 Μαΐου 2013

ios - create unique identifier strings


CFUUIDRef newUniqueID = CFUUIDCreate(kCFAllocatorDefault);

Objects of type CFUUIDRef represent a UUID and are generated using the time, a counter and a hardware identifier, which is usually the MAC address of the ethernet card. 

ios - camera create photo simple steps


source code and explanation are from ios Programming The Big Nerd Ranch Guide 3rd Edition
  1. add an UIImageView
  2. in the attributes inspector find the Mode attribute and change it to Aspect Fit (this will resize the image to fit within the bounds of the UIImageView).
  3. add an UIToolbar, click on single button and change Identifier to Camera. 
  4. ctrl+click and drag the photo icon from toolbar at .h file and create an action
  5. on .h file conform with the following protocols 
    <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
  6. put that code on the above action
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
    //if our device has a camera, we want to take a picture, otherwise, we
    //just pick from photo lirary  
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    }
    else
    {
        [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    }
    [imagePicker setDelegate:self];
    
    [self presentViewController:imagePicker animated:YES completion:nil];

to Save the picture we need to implement the 

Πέμπτη, 9 Μαΐου 2013

IBM WEBCAST - 5 Secrets to Building Engaging Customer Apps && Collabode






Jerry Cuomo,
IBM Fellow, VP, WebSphere Chief Technology Officer
  1. Location & Time drive context
  2. Social & Behavior drive insight
  3. Cross Channel delivers 360 experience
  4. Securely integrated SoE and SoR
  5. Enabling Detect, Enrich, Perceive, Act
    1. Detect: opportunities to engage customers (and employees),  customer loads the App on their smart phone
    2. Enrich: interaction context with historical data and trends get customer profile, favorite cab, favorite destinations
    3. Perceive, “in-the-now” dynamic  interaction context from location, time, social media and other events, location of the  customer, location of  the closest cab, other  nearby friends heading to the same destination
    4. Act: on the insight gained through enrichment and perception to enable positive business outcomes, connect the cab and the customer through notifications and enable customer to pay through the App


Angela Chang,
Software Engineer, Google
Models for close Synchronous collaboration


  • Pair programming (same screen)
    • Asymmetrical  (control of typing, type of thinking)
    • Inefficient
  • Version control 
    • Opaque
    • Merge conflicts
    • Close collaboration is difficult
  • Collabode
    • Real-time
    • Collaborative
    • web-based IDE
    • Eclipse (server-side)
      • project menagement
      • Standard IDE services: continuous compilation, compilers errors and warnings, code formatting and refactoring and execution
      • code is not integrated into other programmers views until its compiled 
    • Etherpad
  • Test-driven development
    • tests and features written in parallel
    • tests are available as they are written
    • faster more reliable development cycles
  • Software engineering education
    • Continuous monitoring of 
      • student progress
      • time spent per task or assignment
      • grasp of lecture topics via tests results or console output
      • commonly encountered errors
    • Collabode can help instructors structure lessons and identify problem topics. 
  • Crowdsourcing
    • Outsourcing coding tasks a la Amazon |Mechanical Turk, TaskRabbit, oDesk ..
    • break a large project into small, well-defined tasks
    • Outsource tasks to a pool of trusted programmers. 
    • Reduces workload on original developer and frees up time to work on core functionality. 
  • Crowdsourcing code with oDesk
    • Defining tasks
    • Verifying programming ability
      • can you trust your programmer tool?
      • What's a good way to build up a sizeable pool?
    • Availability
      • Are programmers there when you need them?
    • Setting time limits/estimates and deadlines
      • How long does it take programmers to finish a task?
      • How closely does ti match with your expectations?
  • Collabode solves the problems with traditional code collaboration
    • Allows programmers to work
      • synchronously
      • transparently
      • without danger of merge conflicts
      • while collaborating closely
    • Enables new models of collaboration 
      • Synchronous test-driven development
      • Code monitoring in the classroom
      • Crowdsourcing code tasks
  • Existing Cloud IDEs
    • Cloud9 IDE
    • Codeanywhere
    • Cloud IDE (a.k.a. eXo Cloud IDE)
    • ... many more
  • Collabode