iOS Interview Questions And Answers

1_h1kjhezFp3MYXCtOxMz4yg

  • What is made up of NSError object?
    There are three parts of NSError object a domain, an error code, and a user info dictionary. The domain is a string that identifies what categories of errors this error is coming from.
  • What is the difference strong, weak, read only and copy ?

    strong, weak, assign property attributes define how memory for that property will be managed.

    Strong means that the reference count will be increased and
    the reference to it will be maintained through the life of the object

    Weak, means that we are pointing to an object but not increasing its reference count. It’s often used when creating a parent-child relationship. The parent has a strong reference to the child but the child only has a weak reference to the parent.

    Read only, we can set the property initially but then it can’t be changed.

    Copy, means that we’re copying the value of the object when it’s created. Also prevents its value from changing.

  • What’s the difference between the frame and the bounds? 
    The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).

    The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.

    So, imagine a view that has a size of 100×100 (width x height) positioned at 25,25 (x,y) of its superview. The following code prints out this view’s bounds and frame:

    // This method is in the view controller of the superview
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        NSLog(@"bounds.origin.x: %f", label.bounds.origin.x);
        NSLog(@"bounds.origin.y: %f", label.bounds.origin.y);
        NSLog(@"bounds.size.width: %f", label.bounds.size.width);
        NSLog(@"bounds.size.height: %f", label.bounds.size.height);
    
        NSLog(@"frame.origin.x: %f", label.frame.origin.x);
        NSLog(@"frame.origin.y: %f", label.frame.origin.y);
        NSLog(@"frame.size.width: %f", label.frame.size.width);
        NSLog(@"frame.size.height: %f", label.frame.size.height);
    }

    And the output of this code is:

    bounds.origin.x: 0
    bounds.origin.y: 0
    bounds.size.width: 100
    bounds.size.height: 100
    
    frame.origin.x: 25
    frame.origin.y: 25
    frame.size.width: 100
    frame.size.height: 100

    So, we can see that in both cases, the width and the height of the view is the same regardless of whether we are looking at the bounds or frame. What is different is the x,y positioning of the view. In the case of the bounds, the x and y coordinates are at 0,0 as these coordinates are relative to the view itself. However, the frame x and y coordinates are relative to the position of the view within the parent view (which earlier we said was at 25,25).

    There is also a great presentation that covers UIViews. See slides 1-20 which not only explain the difference between frames and bounds but also show visual examples.

  • Explain MVC

    • The model is the brain of the application. It does the calculations and creates a virtual world for itself that can live without the views and controllers. In other words, think of a model as a virtual copy of your application, without a face!
    • A view is the window through which your users interact with your application. It displays what’s inside the model most of the time, but in addition to that, it accepts users’ interactions. Any interaction between the user and your application is sent to a view, which then can be captured by a view controller and sent to the model.
    • Controllers in iOS programming usually refer to view controllers. Think of view controllers as a bridge between the model and your views. They interpret what is happening on one side (what the user does on the view side, or the information provided by the model) and use that information to alter the other side as needed.
  • 32- Explain MVVM
    MVVM in iOS means creating an object filled with data that your screen uses, separately from your Model classes. It usually maps all the items in your UI that consume or produce data, like labels, textboxes, datasources or dynamic images. It often does some light validation of input (empty field, is valid email or not, positive number, switch is on or not) with validators. These validators are usually separate classes not inline logic.

    Your View layer knows about this VM class and observes changes in it to reflects them and also updates the VM class when the user inputs data. All properties in the VM are tied to items in the UI. So for example a user goes to a user registration screen this screen gets a VM that has none of it’s properties filled except the status property that has an Incomplete status. The View knows that only a Complete form can be submitted so it sets the Submit button inactive now.

    Then the user starts filling in it’s details and makes a mistake in the e-mail address format. The Validator for that field in the VM now sets an error state and the View sets the error state (red border for example) and error message that’s in the VM validator in the UI.

    Finally, when all the required fields inside the VM get the status Complete the VM is Complete, the View observes that and now sets the Submit button to active so the user can submit it. The Submit button action is wired to the VC and the VC makes sure the VM gets linked to the right model(s) and saved. Sometimes Models are used directly as a VM, that might be useful when you have simpler CRUD-like screens.

    I’ve worked with this pattern in WPF and it works really great. It sounds like a lot of trouble setting up all those observers in Views and putting a lot of fields in Model classes as well as ViewModel classes but a good MVVM framework will help you with that. You just need to link UI elements to VM elements of the right type, assign the right Validators and a lot of this plumbing gets done for you without the need for adding all that boilerplate code yourself.

    Some advantages of this pattern:

    • It only exposes the data you need
    • Better testability
    • Less boilerplate code to connect UI elements to data

    Disadvantages:

    • Now you need to maintain both the M and the VM
    • You still can’t completely get around using the VC iOS.
  • What is the Swift main advantage?
    To mention some of the main advantages of Swift:

    • Optional Types, which make applications crash-resistant
    • Built-in error handling
    • Closures
    • Much faster compared to other languages
    • Type-safe language
    • Supports pattern matching
  • Swift’s pattern matching techniques

    • Tuple patterns are used to match values of corresponding tuple types.
    • Type-casting patterns allow you to cast or match types.
    • Wildcard patterns match and ignore any kind and type of value.
    • Optional patterns are used to match optional values.
    • Enumeration case patterns match cases of existing enumeration types.
    • Expression patterns allow you to compare a given value against a given expression.
  • What are benefits of Guard?
    There are two big benefits to guard. One is avoiding the pyramid of doom, as others have mentioned — lots of annoying if let statements nested inside each other moving further and further to the right. The other benefit is provide an early exit out of the function using break or using return. For more details please got to the link.
  • What is NSFetchRequest?

    NSFetchRequest is the class responsible for fetching from Core Data. Fetch requests are both powerful and flexible. You can use fetch requests to fetch a set of objects meeting the provided criteria, individual values and more.

    let request: NSFetchRequest<NSFetchRequestResult> = Level.fetchRequest()

    or

    let request: NSFetchRequest<Level> = Level.fetchRequest()

     

  • Explain NSFetchedResultsController?

    NSFetchedResultsController is a controller, but it’s not a view controller. It has no user interface. Its purpose is to make developers’ lives easier by abstracting away much of the code needed to synchronize a table view with a data source backed by Core Data.

    Set up an NSFetchedResultsController correctly, and your table will mimic its data source without you have to write more than a few lines of code.

  • Explain Forced Unwrapping

    When we defined a variable as optional, then to get the value from this variable, we will have to unwrap it. This just means putting an exclamation mark at the end of the variable.

 

 

ASP.NET – jQuery is not Working in UpdatePanels

The following code that anyone can use to make sure on each Postback and on each asynchronous Postback the JavaScript code will still be executed.

In my case, I had a user control within a page. Just paste the below code in your user control.

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
if (args.get_error() == undefined) {
UPDATEPANELFUNCTION();
}
}
function UPDATEPANELFUNCTION() {
jQuery(document).ready(function ($) {
/* Insert all your jQuery events and function calls */
});
}
UPDATEPANELFUNCTION();

Check box list Scrolling to Top on autopostback

Problem: When you check any check box with OnSelectedIndexChanged event added, post back happens and the scroll position is set to 1st check box. If the list is very long, it becomes inconvenient for user to scroll back again where he left. To overcome this, vertical scroll position should be set on every selected check box.

Solution: Java Script code is added on the page which sets the position again on every post back.

Below shown is the checkbox list which I have added in update panel so that there is no refresh to the page when OnSelectedIndexChanged method is called.

<asp:UpdatePanel runat=”server” ID=”upCheckBoxList”>

<ContentTemplate>

<fieldset style=”border: none”>

</fieldset>

</ContentTemplate>

</asp:UpdatePanel>

I have placed checkbox list in a div and now javascript is added to the head section of the page to hold the vertical scroll position as shown below:

<script type=”text/javascript”>

var xPos, yPos;

var prm = Sys.WebForms.PageRequestManager.getInstance();

function BeginRequestHandler(sender, args) {

if ($get(‘<%=Div1.ClientID%>’) != null) {

xPos = $get(‘<%=Div1.ClientID%>’).scrollLeft;

yPos = $get(‘<%=Div1.ClientID%>’).scrollTop;

}

}

function EndRequestHandler(sender, args) {

if ($get(‘<%=Div1.ClientID%>’) != null) {

xPos = $get(‘<%=Div1.ClientID%>’).scrollLeft = xPos;

yPos = $get(‘<%=Div1.ClientID%>’).scrollTop = yPos;

}

}

prm.add_beginRequest(BeginRequestHandler);

prm.add_endRequest(EndRequestHandler);

</script>

Now if you scroll to the lowest and select a value, scroll position will not change. 🙂

ASP.NET Web Site or ASP.NET Web Application?

Website:

The Web Site project is compiled on the fly. You end up with a lot more DLL files, which can be a pain. It also gives problems when you have pages or controls in one directory that need to reference pages and controls in another directory since the other directory may not be compiled into code yet. Another problem can be in publishing.

If Visual Studio isn’t told to re-use the same names constantly, it will come up with new names for the DLL files generated by pages all the time. That can lead to having several close copies of DLL files containing the same class name, which will generate plenty of errors. The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be extremely popular.

Web Application:

The Web Application Project was created as an add-in and now exists as part of SP 1 for Visual Studio 2005. The main differences are the Web Application Project was designed to work similar to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build time. In order to update the project it must be recompiled and the DLL file published for changes to occur.

Another nice feature of the Web Application project is it’s much easer to exclude files from the project view. In the Web Site project, each file that you exclude is renamed with an exclude keyword in the filename. In the Web Application Project, the project just keeps track of which files to include/exclude from the project view without renaming them, making things much tider.

The article ASP.NET 2.0 – Web Site vs Web Application project also gives reasons on why to use one and not the other. Here is an excerpt of it:

  • You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
  • You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
  • You need to add pre-build and post-build steps during compilation? use Web Application project.
  • You need to build a Web application using multiple Web projects? use Web Application project.
  • You want to generate one assembly for each page? use Web Site project.
  • You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project.
  • You prefer single-page code model to code-behind model? use Web Site project.

asp net blogger engine integration

Please find the step by step guide how to integrate this existing application. Moreover also you find the solutions to integrate with asp.net application as there is some complexities involved in integrating this BlogEngine web site project with asp.net web application. You can just follow below instruction then it is done.

Get the web project folder

Now that you have a downloaded zip file, you need to un-zip it. This can be done with a bunch of different utilities and in a bunch of different methods.

If you choose the Web Project download, your newly unzipped folder contains the web project you want to work with. If you download the source code, the web project is buried a little bit. The web project is found under the BlogEngine.NET folder, then the BlogEngine folder.

Load the web project on your web server

Now that you have the web project folder, copy those files and folders out to your web server. This usually involves FTP, but depending on your situation, it might even require a portable storage device (e.g. USB flash drive).

Set folder as a .NET 4.0 application

There isn’t much to say about this. If you have direct IIS access, you need to create an application. If you are using a hosted provider, you need to use their control panel to make this happen. It should be a standard option, but if you don’t find it, you may need to contact your hosting provider for support.

Add write permissions for App_Data folder

This is an often forgotten step. If you miss it, you’ll notice as soon as you try to make a change. You need to give the application write permissions to the App_Data folder. Again, your hosting provider may have a control panel that allows you to do this. If not, you may need to contact your hosting provider for support.

Setting write permissions could involve up to 3 steps:

1) Using the IIS admin tool or your hosting provider’s control panel, set the folder as “Write” capable;

2) If you have direct access to the file system, make sure the account under which the BlogEngine.NET’s application pool is running (typically “ASPNET” on XP / 2003 and “Network Service” on Vista / 2008) has write access to the physical folder;

3) After unzipping the web folder, all files have their read-only attribute enabled. Turn that attribute off for the App_Data folder and all files and sub-folders.

Navigate to the web page

Ok, now you are ready to navigate to the web site and see how you did. For example, if you installed the web site to your local machine for testing, you would navigate to http://localhost/default.aspx. You can also edit the default document to display to default.aspx using the IIS MMC snap-in. If you do this, you can navigate directly to http://localhost/ without specifying the page name. If all goes well, you are greeted by the default blog page.

Login and Setup your user name

The last step is to scroll down and find the sign in link on the right side. Click Sign in and then login in the following information.

User Name: admin Password: admin

Once you login, you will see a new menu on the right hand side. Click Users.

Create a new user for yourself. The user name you choose is your display name. See the User Administration page for more information.

Delete the admin account. You don’t want everyone who reads this to be able to login to your blog, do you?

Finally, log out, then log back in using the user account you just created for yourself.

The above installation is for, if we want to run the blog as a stand alone site which is rare specially in our case, *so lets include our blog within our site so that we will not have to redirect to another site to just go to the Blog or from blog to the main web site.*enter code here

Include the Blog Engine site to our own Project:

1:Create a folder inside root named Blog or as you want to name it. Copy the whole Blog Engine .net site inside this folder except App_Global Resources,App_Code,Web.Config, robots.txt, web.sitemap and Global.asax.

2:Rename the App_Code folder to BlogApp_Core or as you want. Because App_Code folders will not work with web application as they work with the web sites. Now Copy this folder to the Root of the project.

3:Merge or Copy the App_Global Resources robots.txt and web.sitemap to the Root of the project.

4:Add the Blog Engine.core project in the Web Application. Build Blog Engine.core and add reference from your web project to “BlogEngine.Core.dll”.

5:Web.Config Changes If you already have a web.config in place then merge the Blog’s Web.Config with it otherwise just copy it to the root. Go to the line in pages section change that to where “BlogWap” is the Web Project Name. Go to the line change this to where Blog is the Folder name that we have created earlier.

If you want to use SQL As database we have to go for some more changes

Get or Write Image Metadata in C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.IO;
public class clsReadMetaData
{

public ImageMetadata ReadEXIFMetadata(string filepath)
{
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
Image image__1 = Image.FromStream(fs);
PropertyItem[] imagePropertyItems = image__1.PropertyItems;
ImageMetadata imageMetadata = new ImageMetadata();
foreach (PropertyItem pi in imagePropertyItems)
{
switch ((EXIFProperty)pi.Id)
{
case EXIFProperty.Title:
imageMetadata.Title = Encoding.Unicode.GetString(pi.Value);
//imageMetadata.Title = Encoding.UTF32.GetString(pi.Value)
break;
case EXIFProperty.Author:
imageMetadata.Author = Encoding.Unicode.GetString(pi.Value);
//imageMetadata.Author = Encoding.UTF8.GetString(pi.Value)
break;
case EXIFProperty.Keywords:
imageMetadata.Keywords = Encoding.Unicode.GetString(pi.Value);
//imageMetadata.Keywords = Encoding.UTF8.GetString(pi.Value)
break;
case EXIFProperty.Comments:
imageMetadata.Comments = Encoding.Unicode.GetString(pi.Value);
//imageMetadata.Comments = Encoding.UTF8.GetString(pi.Value)
break;
default:
break;
}
}
fs.Close();
return imageMetadata;
}
public void SaveEXIFMetadata(Image image, ImageMetadata metadata, string filepath)
{
SaveEXIFMetadataProperty(image, EXIFProperty.Title, metadata.Title, filepath);
SaveEXIFMetadataProperty(image, EXIFProperty.Author, metadata.Author, filepath);
SaveEXIFMetadataProperty(image, EXIFProperty.Keywords, metadata.Keywords, filepath);
SaveEXIFMetadataProperty(image, EXIFProperty.Comments, metadata.Comments, filepath);
}
private void SaveEXIFMetadataProperty(Image image, EXIFProperty property, string propertyValue, string filepath)
{
PropertyItem propertyItem = CreatePropertyItem();
propertyItem.Id = Convert.ToInt32(property);
// Type=1 means Array of Bytes. 
propertyItem.Type = 2;
propertyItem.Len = propertyValue.Length;
//propertyItem.Value = Encoding.Unicode.GetBytes(propertyValue)
propertyItem.Value = Encoding.UTF8.GetBytes(propertyValue);
image.SetPropertyItem(propertyItem);
image.Save(filepath);
}
private PropertyItem CreatePropertyItem()
{
System.Reflection.ConstructorInfo ci = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, new Type[0], null);
return (PropertyItem)ci.Invoke(null);
}
}
public enum EXIFProperty
{
Title = 40091,
Author = 40093,
Keywords = 40094,
Comments = 40092
}
public class ImageMetadata
{
private string _title = string.Empty;
private string _author = string.Empty;
private string _keywords = string.Empty;
private string _comments = string.Empty;
public ImageMetadata()
{
this._title = string.Empty;
this._author = string.Empty;
this._keywords = string.Empty;
this._comments = string.Empty;
}
public ImageMetadata(string title, string author, string keywords, string comments)
{
this._title = title;
this._author = author;
this._keywords = keywords;
this._comments = comments;
}
public string Title
{
get
{
return this._title;
}
set
{
this._title = value;
}
}
public string Author
{
get
{
return this._author;
}
set
{
this._author = value;
}
}
public string Keywords
{
get
{
return this._keywords;
}
set
{
this._keywords = value;
}
}
public string Comments
{
get
{
return this._comments;
}
set
{
this._comments = value;
}
}
}

10 SIGNS YOU STILL HAVE FEELINGS FOR YOUR FIRST LOVE

1.Think About Them Everyday

You think about them almost every day. You do not do it consciously – but one train of thought leads to another and BAM! Before you know it, you’re thinking about them even before you realize it.

2.Stalking Social Networking Profiles

You stalk their Facebook profile more frequently than you would ever care to admit. You tell yourself that you’ll just scroll through the main profile for a few seconds – and soon you are digging into each comment under each post and photo.

3.Still Dream About Them

You still have vivid dreams about them on random nights and you wake up feeling confused the next day. Sometimes you get up so disoriented; it actually takes you a couple of minutes to get back to reality.

4.Compare Them With Other Lovers

You cannot help but compare your new partners to your first love subconsciously. You might be in a happy relationship yourself presently, but you go through with the ‘what if’ scenarios too often in your head for it to be healthy. 

5.Undying Hope Of Reunion

Some part of you still thinks that there is a remote possibility that you two will end up together in the future. It does not matter that they are seeing other people, or you two have not been in touch for years – you just feel (or really hope, to be precise) that destiny will turn things around one day.

6.Feelings About Revisiting Old Places

You cannot go to the same places you used to hang out with them in the past without feeling either very nostalgic or very uncomfortable – whether it’s a street corner or a coffee shop. Either way, you can just see old memories play out behind your eyes when you are there.

7.Know More VS. Show Less

7 of 10 10 Signs You Still Have Feelings For Your First Love

When you meet common friends who do not know you still care for your ex, you are faced with a dilemma of wanting to know more about how the person is doing versus trying to appear ice-cool on the outside. But if your friends do know about your feelings, you will drop that cool façade and hound them for every little detail… every time.

8.Nostalgia Nights

You think it’s perfectly okay to sometimes dedicate an entire evening drinking alone and thinking about them while listening to the songs you remember them by. It’s catharsis, you tell yourself, as you line up your playlist with numbers that both of you loved listening to.  

9. Remember Every Tiny Detail

Most importantly, you can recall with exact details how you felt when you met them for the first time. It was probably because you were feeling those feelings for the first time… or they were teenage hormones, but if years later you can still revisit those memories in clear detail, you’re still very much in love with your first love, mate! 

#Rinks 

 

 

 

 

#Quote

aahista chal zindagi, abhi kai karz chukana baaki hai

kuch dard mitana baaki hai, kuch farz nibhana baaki hai

raftaar mein tere chalne se kuchh rooth gaye, kuch chhoot gaye

roothon ko manana baaki hai, roton ko hasana baki hai

kuch hasraatein abhi adhuri hain, kuch kaam bhi aur zaruri hai

khwahishen jo ghut gayi iss dil mein, unko dafnana baki hai

kuch rishte ban kar toot gaye, kuch judte-judte chhoot gaye

Un toote-chhoote rishton ke zakhmon ko mitana baki hai

tu aage chal main aata hoon, kya chhod tujhe ji paunga?

in saanson par haqq hai jinka, unko samjhaana baaki hai

aahista chal zindagi, abhi kai karz chukana baki hai

pattyf56_gif_smile_021212121111-705821

Awesome Conversation between God And a Man. Read it and don’t forget to share it with your friends.

Awesome Conversation between God And a Man. Read it and don’t forget to share it with your friends.

Man: God, can I ask You a question

God: Sure

Man: Promise You won’t get mad …

God: I promise

Man: Why did You let so much stuff happen to me today

God: What do u mean

Man: Well, I woke up late

God: Yes

Man: My car took forever to start

God: Okay

Man: at lunch they made my sandwich wrong & I had to wait

God: Huummm

Man: On the way home, my phone went DEAD, just as I picked up a call

God: All right

Man: And on top of it all off, when I got home ~I just want to soak my feet in my new foot massager & relax. BUT it wouldn’t work!!! Nothing went right today! Why did You do that

God: Let me see, the death angel was at your bed this morning & I had to send one of My Angels to battle him for your life. I let you sleep through that

Man (humbled): OH

GOD: I didn’t let your car start because there was a drunk driver on your route that would have hit you if you were on the road.

Man: (ashamed)

God: The first person who made your sandwich today was sick & I didn’t want you to catch what they have, I knew you couldn’t afford to miss work.

Man (embarrassed): Okay

God: Your phone went dead bcuz the person that was calling was going to give false witness about what you said on that call, I didn’t even let you talk to them so you would be covered.

Man (softly): I see God

God: Oh and that foot massager, it had a shortage that was going to throw out all of the power in your house tonight. I didn’t think you wanted to be in the dark.

Man: I’m Sorry God

God: Don’t be sorry, just learn to Trust Me…. in All things , the Good & the bad.

Man: I will trust You.

God: And don’t doubt that My plan for your day is Always Better than your plan.

Man: I won’t God. And let me just tell you God, Thank You for Everything today.

God: You’re welcome child. It was just another day being your God and I Love looking after My Children..