Skip to main content

Program Objective-C

1 - A Program in Objective C Method Function Declaration, Definition With Calling.

#import <Foundation/Foundation.h>

@interface SampleClass: NSObject

-(int)max:(int)num1 secondNumber:(int)num2;

@end

@implementation SampleClass

-(int)max:(int)num1 secondNumber:(int)num2
{
int result;
if(num1 > num2)
{
result = num1;
}
else{
result = num2;
}
return result;
}
@end

//Variable declaration
int a;
int b;
int main()
{
//Variable defination
int a = 10;
int b = 20;
int c;
int ret;
c = a + b;
NSLog(@"Value of c : %d \n", c);
f = f/10.10;
NSLog(@"Value of c : %f \n", f);
SampleClass *sampleClass = [[SampleClass alloc]init];
ret =  [sampleClass max:a secondNumber:b];
NSLog( @"Max value is :%d\n", ret );

return 0;

}

Object Oriented Programming Feature in Swift


Classes and Objects

Create A Class 

Class A{
//Empty Class
}
Create a new instance new Object in a Class A
Class A{
var new = A()
}

Properties 

Class B{

var data: Int = 10

}

1 TO 5 - Number Pattern Program in Objective C

(1):- 

12345
1234
123
12
1

#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int i, j;    
    for(i=5; i>=1; i--)  
{
   for(j=1; j<=i; j++)      
 {          
         NSLog(@"%i", j);    
    }      
         NSLog(@"");
   
}
[pool drain];
return 0;
}

(2):- 

5
54
543
5432
54321


#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int i, j;  
for(i=5; i>=1; i--)
        {  
for(j=5; j>=i; j--)    
{        
NSLog(@"%i", j);    
}      
NSLog(@"");  
}
[pool drain];
return 0;
}

(3):- 

54321
4321
321
21
1

#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int i, j;  
for(i=5; i>=1; i--)
 {      
for(j=i; j>=1; j--)
          
NSLog(@"%i", j);      
}
       
NSLog(@"");
   
}

[pool drain];
return 0;
}

(4):- 

54321
5432
543
54
5

#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int i, j;
   
for(i=5; i>=1; i--)
   
 {
       
for(j=i; j>=1; j--)          
NSLog(@"%i", j);
     
}
       
NSLog(@"");
   
}
[pool drain];

return 0;
}

(5):- 

5
45
345
2345
12345

#import <Foundation/Foundation.h>


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

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int i, j;
   
for(i=5;i>=1;i--)
   
  {
       
for(j=i;j<=5;j++)
       
{          
NSLog(@"%d", j);
       
  }
       
NSLog(@"");
   
 }
 

[pool drain];

return 0;

}



(6):-

1
21
321
4321
54321

#import <Foundation/Foundation.h>


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

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


for(i=1;i<=5;i++)

 {

for(j=i;j>=1;j--)

 {                  
NSLog(@"%d", j);
       
  }
       
NSLog(@"");
   
 }
 

[pool drain];

return 0;

}


(7):-

5
54
543
5432
54321

#import <Foundation/Foundation.h>


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

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


for(i=5;i>=1;i--)
{

for(j=5;j>=i;j--)

{                
NSLog(@"%d", j);
       
  }
       
NSLog(@"");
   
 }
 

[pool drain];

return 0;

}


(8):-

1
22
333
4444
55555

#import <Foundation/Foundation.h>


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

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


for(i=1;i<=5;i++)

{

for(j=1;j<=i;j++)

{                
NSLog(@"%d", j);
       
  }
       
NSLog(@"");
   
 }
 
[pool drain];

return 0;



Comments

Popular posts from this blog

How Create Animated Circle Progress Bar iOS 11 Swift 4

Animated Circle Progress Bar iOS 11 Swift 4


With MBCircularProgressBar - https://github.com/MatiBot/MBCircularProgressBar


A circular, animatable & highly customizable progress bar from the Interface Builder Swift, Using pod fite MBCircularProgressBar Installation Cocoapods terminal.

pod "MBCircularProgressBar"

That - A Simple Steps to installed pod file -        Open terminal       Command on terminal go to project folder Cd path       set your project path on terminal.       command : pod init       open pod file - open -e podfile       added in pod file with in : pod "MBCircularProgressBar"       Command : Pod install       Close project of Xcode       open your Project from terminals       Command : open PodDemos.xcworkspace After opern StoryBoard and Now drag a UIView over the viewController in storyboard

Or set UIView Constraint width, height or verticle or horzentail space and set a class MBCircularProgressBarView in StoryBoard. Open Atribute inspector and cu…

Facebook Login - Facebook Authentication and Cocoapods

Create a new application facebook login and authentication a facebook user using their iOS SDK with Cocoapods. Below are the steps in which we'll be following: First Getting Started guide from Facebook's iOS SDK Documentation Create a new iOS project Swift


Open facebook Developer Account and create new App after go to setting and click basic -> add platform ios
https://developers.facebook.com/docs/ios/getting-started
https://developers.facebook.com/ Then add Bundle id your ios project like com.xxxx, Configuring Facebook with Bundle ID Then go ahead Download facebook sdk for ios other wise install pod file your project.
Go ahead to open terminal and go ahead your project folder.

Got create podfile -> pod init
Open podfile -> open podfile Paste ->  pod 'FBSDKCoreKit' 
               pod 'FBSDKShareKit' 
               pod 'FBSDKLoginKit' podfile and save

Then go to terminal or install podfiles -> pod Install
Like

Enabling Facebook's Authentication Mech…

Core Data With Swift 4.0 Tutorial

Core Data - Core Data is a framework that you use to manage the data model layer objects or instance Context in your application. It provides generalized and automated data stores solutions to common tasks associated with object life cycle and object graph management, including persistence.
Completely Tutorial for Swift 4 and iOS 11. Gating Start Goto Xcode and create New iOS Project on single view. Project Name CoreDataSwift or Checked Use Core Data

On click Main.Storyboard in Interface builder click on project navigation Editor - Embed In - Navigation controller.



Then After click on Navigation ViewController and next Drag TableView in to ViewController.


Make TableView viewcontroller Outlet Delegate, DataSource and import CoreData

import UIKit import CoreData
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { overridefunc viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } overridefunc didReceiveMem…