Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9157859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:07:12+00:00 2026-06-17T13:07:12+00:00

I created simple NSObject class to take some values. My application has not come

  • 0

I created simple NSObject class to take some values. My application has not come any error when I run and build the application. I tried it lot of time to run program. I am beginner of the objective c.

Code ::

#import "FibonachiNo.h"

@implementation FibonachiNo

- (NSArray *) fibonacci:(NSInteger) n {

    NSMutableArray *fib = [NSMutableArray array];

    int a = 0;
    int b = 1;
    int sum;
    int i;

    for (i=0; i<=n; i++)
    {
        [fib addObject:[NSNumber numberWithInt:a]];
        sum = a + b;
        a = b;
        b = sum;
    }

    return (NSArray *) fib;
}

- (NSInteger) factorial:(NSInteger) n {
    if ( n <= 1 )
        return 1;
    else
        return n * [self factorial:( n-1 )];
}

@end

My application header class

#import <UIKit/UIKit.h>
#import "FibonachiNo.h"
@interface ViewController : UIViewController
@property FibonachiNo *myFibonachi;
@end

Calling Method to NSObject Class ::

  NSLog(@"fibonacci for 10 = %@", [myFibonachi fibonacci:10]);
  NSLog(@"10! = %d",[myFibonachi factorial:10]);

Is it any wrong in this calling method ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:07:13+00:00Added an answer on June 17, 2026 at 1:07 pm

    first alloc init your Array

    #import "FibonachiNo.h"
    
    @implementation FibonachiNo
    
    - (NSArray *) fibonacci:(NSInteger) n {
    
        NSMutableArray *fib = [NSMutableArray alloc]init];
    
        int a = 0;
        int b = 1;
        int sum;
        int i;
    
        for (i=0; i<=n; i++)
        {
            [fib addObject:[NSNumber numberWithInt:a]];
            sum = a + b;
            a = b;
            b = sum;
        }
    
        return fib;
    }
    
    - (NSInteger) factorial:(NSInteger) n {
        if ( n <= 1 )
            return 1;
        else
            return n * [self factorial:( n-1 )];
    }
    
    @end
    

    Calling Method to NSObject Class ::

    in ViewDidLoad use following.

    FibonachiNo *myFibonachi=[[FibonachiNo alloc]init];
      NSLog(@"fibonacci for 10 = %@", [myFibonachi fibonacci:10]);
      NSLog(@"10! = %d",[myFibonachi factorial:10]);
    

    if still you facing any issue , then show your NSLog output here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a simple Person.h class: #import <Foundation/Foundation.h> @interface Person : NSObject { int
This is a simple class ive created in C++ for a musical application im
I am new to Repository concept and get some questions. I have created simple
I created a simple tooltip for some buttons in an admin panel I am
I created a simple Sudoku application, where each 3x3 squares is a user control,
I created a simple login system using sql It has 4 main components index
If i create a simple class like this @interface table : NSObject { NSMutableArray
I have this simple class TestViewController.h #import <UIKit/UIKit.h> #import ClassB.h @protocol TestViewControllerDelegate <NSObject> -(void)hello;
I have a simple Answer class that looks like this: @interface Answer : NSObject
I have created simple .aspx page which queries a database for some live data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.