hit counter

Timeline

My development logbook

Make Iphone Vibrate

Use these APIs to set the iphone to vibrate

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

The first function plays a beep sound if the devices don’t support vibration. The second function on the other hand does nothing on unsupported devices.

if AVRecorder is running, iphone will not vibrate too.

Source: Stackoverflow

Difference Between Handling ‘Self’ in Python and Swift

Take a look at this swift code (XCode6 Beta7)

    class C {
            func name () -> String {
                return "C"
            }
    }

    class D:C {
            override func name () -> String {
                return "D"
            }
    }

    let c = C()
    println(c.name()) // print 'C'

    let d = D()
    println(d.name()) // print 'D' as expected

    println(C.name(d)()) // print 'D'! 

In python, the last case is different:

    class C:
        def name(self):
            return 'C' 

    class D(C):
        def name(self):
            return 'D' 

    c = C() 
    print(c.name())  // print 'C' 

    d = D() 
    print(d.name())  // print 'D' 

    print(C.name(d)) // print 'C' 

ngTouch

To introduce touch behaviour in angularjs-enabled mobile app, try this:

<script src="bower_components/angular-touch/angular-touch.js"></script>
angular.module('myApp', ['ngTouch']) 

Semi-colon in Swift

The perfered style of semi-colon placement in swift is:

1
2
3
4
5
6
7
struct Foo: SomeProtocol {}
class Foo: SomeProtocol {}

var x: Int
func foo(x: Int) {}
func bar(x: (y: Int) -> Int) -> Double {}
let dict = ["key": value]

i.e. No space before the semi-colon. One space after the semi-colon

What Is Tag Fieldset?

From StackOverflow

The most obvious, practical example is:

<fieldset>
    <legend>Colour</legend>
    <label><input type="radio" name="colour" value="blue"> Blue </label>
    <label><input type="radio" name="colour" value="red"> Red </label>
    <label><input type="radio" name="colour" value="green"> Green </label>
</fieldset>

This allows each radio button to be labeled while also providing a label for the group as a whole. This is especially important where assistive technology (such as a screen reader) is being used where the association of the controls and their legend cannot be implied by visual presentation.