Sunday, September 8, 2013

thumbnail

Difference between coredata & sqlite?


There is a huge difference between these two. SQLLite is a database itself like we have MS SQL Server. But CoreData is an ORM (Object Relational Model) which creates a layer between the database and the UI. It speeds-up the process of interaction as we dont have to write queries, just work with the ORM and let ORM handles the backend. For save or retrieval of large data, I recommend to use Core Data because of its abilities to handle the less processing speed of IPhone.

Saturday, September 7, 2013

Sunday, September 1, 2013

thumbnail

3 Tier Architecture For Mobile Development

As a way to learn mobile development I made an iPhone app which I subsequently ported to Android. I felt it important to at least support 2 platforms so that I would learn how to design apps with cross-platform in mind from the start. I’ve come to the conclusion that 3 tier architecture, which is familiar to those in enterprise web development, would be useful in dealing with the cross-platform issue.
3 Tier Architecture
The basic idea is that the core of the application would reside in the domain layer. The interface to the domain and service layers would stay constant so that the domain layer can be easily translated to a new language on a different platform. The UI layer could interact directly with the service layer if there is no application logic in the operation. For example, the UI might show a list of items and can get that directly from a DAO(data access object) but if that list needs to be processed first it should be done in the logic section rather than the DAO or UI layer.
The UI layer consists of things like, on iOS, view controllers and on Android activities. You have to be careful to keep application logic out of this layer as much as possible.
In the domain layer, the model section contains your POJOs (plain old Java objects) and the logic section would use DAOs and other services from the services layer and return data to the UI layer.
The service layer would abstract features of the device like database access, network access, location etc. for the domain and UI layers. It would not only be a wrapper on the device specific API but it could also simplify access to the feature so the domain layer can concentrate on the application logic. For example a location service might deal with different ways of getting one’s location either using GPS or cell towers but the other layers don’t have to know about that implementation detail.

courtesy: http://blog.markhorgan.com/?p=422

Tuesday, August 20, 2013

Saturday, August 17, 2013

thumbnail

Set UILabel height depending on the text

//Calculate the expected size based on the font and linebreak mode of your label
// FLT_MAX here simply means no constraint in height

CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX);

CGSize expectedLabelSize = [myString sizeWithFont:yourLabel.font constrainedToSize:maximumLabelSize lineBreakMode:yourLabel.lineBreakMode];  

//Set the label the the new height.
CGRect newFrame = myLabel.frame;
newFrame.size.height = expectedLabelSize.height;
yourLabel.frame = newFrame;

Thursday, May 30, 2013

Thursday, February 21, 2013

thumbnail

Video Streaming and Playing in iOS objective-C


- (void) PlayVideo:(UIButton *)sender{
   
    NSString *fileName = @"URLSOURCE";
       
    NSURL *streamURL = [NSURL URLWithString:fileName];
    
   mPlayerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:streamURL];
    
    
    [self.view addSubview:mPlayerVC.view];
    
    //play movie
    
    MPMoviePlayerController *player = [mPlayerVC moviePlayer];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    
    player.view.frame = self.view.frame;
    [player setFullscreen:YES animated:YES];
    [self.view addSubview:player.view];
    [player prepareToPlay];
    [player play];
    

}


//============Other Methods====================

- (void)willEnterFullscreen:(NSNotification*)notification {
    NSLog(@"willEnterFullscreen");
}

- (void)enteredFullscreen:(NSNotification*)notification {
    NSLog(@"enteredFullscreen");
}

- (void)willExitFullscreen:(NSNotification*)notification {
    NSLog(@"willExitFullscreen");
}

- (void)exitedFullscreen:(NSNotification*)notification {
    NSLog(@"exitedFullscreen");
    [self.mPlayerVC.view removeFromSuperview];
    self.mPlayerVC = nil;
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)playbackFinished:(NSNotification*)notification {
    NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
    switch ([reason intValue]) {
        case MPMovieFinishReasonPlaybackEnded:
            NSLog(@"playbackFinished. Reason: Playback Ended");
            break;
        case MPMovieFinishReasonPlaybackError:
            NSLog(@"playbackFinished. Reason: Playback Error");
            break;
        case MPMovieFinishReasonUserExited:
            NSLog(@"playbackFinished. Reason: User Exited");
            NSLog(@"exitedFullscreen");
         
            [[NSNotificationCenter defaultCenter] removeObserver:self];
            break;
        default:
            break;
    }
    
    [self.mPlayerVC.view removeFromSuperview];
    self.mPlayerVC = nil;

}


Saturday, January 12, 2013

thumbnail

Basic OOP Concepts

What is the difference between Information Hiding and Encapsulation?

Generally Encapsulation is often referred to as information hiding. Though the two terms are often used interchangeably, Information Hiding is really the result of Encapsulation, not a synonym for it. Both are distinct concepts.

Encapsulation makes it possible to separate an object’s implementation from its behavior - to restrict access to its internal data. This restriction allows certain details of an object’s behavior to be hidden. It allows us to create a “black box” and protects an object’s internal state from corruption by its user.

What is an Interface?

An interface is a contract & defines the requisite behavior of generalization of types.

An interface mandates a set of behavior, but not the implementation. Interface must be inherited. We can't create an instance of an interface.

An interface is an array of related function that must be implemented in derived type. Members of an interface are implicitly public & abstract.

An interface can inherit from another interface.

What is Sealed modifiers?

Sealed types cannot be inherited & are concrete.

Sealed modifiers can also be applied to instance methods, properties, events & indexes. It can't be applied to static members.

Sealed members are allowed in sealed and non-sealed classes.

What is Abstract Class?

Abstract class exists extensively for inheritance. We can't create an instance of an abstract class. Abstract type must be inherited.

Static, Value Types & interface doesn't support abstract modifiers.

Static members cannot be abstract. Classes with abstract member must also be abstract.

What is New modifiers?

The new modifiers hides a member of the base class. C# supports only hide by signature.

What is Virtual keyword?

This keyword indicates that a member can be overridden in a child class. It can be applied to methods, properties, indexes and events.

What is Inheritance?

It provides a convenient way to reuse existing fully tested code in different context thereby saving lot of coding.

Inheritance of classes in C# is always implementation Inheritance.

What is Static Method?

It is possible to declare a method as Static provided that they don't attempt to access any instance data or other instance methods.
What is Static field?

To indicate that a field should only be stored once no matter how many instance of the class we create.
What is Class?

A Class is the generic definition of what an object is a template.

The keyword class in C# indicates that we are going to define a new class (type of object)

What is Object?

Object is anything that is identifiable as a single material item.

Can Struct be inherited?

No, Struct can't be inherited as this is implicitly sealed.

What is Virtual method?

Virtual Method has implementation & provide the derived class with the option to override it.

What is Abstract method?

Abstract method doesn't provide the implementation & forces the derived class to override the method.

What is Polymorphisms?

Polymorphism means one interface and many forms. Polymorphism is a characteristics of being able to assign a different meaning or usage to something in different contexts specifically to allow an entity such as a variable, a function or an object to have more than one form.

There are two types of Polymorphism.
Compile time: function or operator overloading
Runtime: Inheritence & virtual functions


Courtesy: http://discuss.itacumens.com/index.php?topic=26202.0

About me

simple one.