Click here to Skip to main content
15,847,963 members
Home / Discussions / Objective-C and Swift
   

Objective-C and Swift

 
GeneralRe: Crashing in printing Pin
Le@rner11-Apr-17 23:19
Le@rner11-Apr-17 23:19 
QuestionHow to get the sensor data Pin
Member 1302743027-Feb-17 15:56
Member 1302743027-Feb-17 15:56 
AnswerRe: How to get the sensor data Pin
Richard MacCutchan27-Feb-17 22:22
mveRichard MacCutchan27-Feb-17 22:22 
Questionimage from custom NSView , image quality is very bad. Pin
Le@rner16-Jan-17 19:50
Le@rner16-Jan-17 19:50 
AnswerRe: image from custom NSView , image quality is very bad. Pin
Surya_Narayan11-Apr-17 0:31
professionalSurya_Narayan11-Apr-17 0:31 
GeneralRe: image from custom NSView , image quality is very bad. Pin
Le@rner11-Apr-17 23:17
Le@rner11-Apr-17 23:17 
QuestionSimultaneous Microphone Access on iPhone Pin
Member 123773388-Mar-16 1:35
Member 123773388-Mar-16 1:35 
QuestionObjective C first program from the book, warning messages Pin
Alla__10-Nov-15 2:44
Alla__10-Nov-15 2:44 
Hello!

I am new to this forum, and new to programming, although I have already reached chapter 18
of Programming in C textbook.

Please, take a look at the program I typed in from the book, and warning messages I receive.
I would be grateful for explanation on what I am doing wrong. I work on Mac OS 10.7.5, Xcode 4.6.3,
Terminal 2.2.3.
1) I created a file with the command:
touch prog18-2.m// Program ot work with fractions - Objective-C version

2) Program
#import <stdio.h>
#import <objc object.h="">

//------ @interface section ---------

@interface Fraction: Object
{
int numerator;
int denominator;
}
-(void) set_numerator: (int) n;
-(void) set_denominator: (int) d;
-(void) print;

@end

// ----- @implementation section -------

@implementation Fraction;

// getters
-(int) numerator
{
return numerator;
}

-(int) denominator
{
return denominator;
}

//setters
-(void) set_numerator: (int) num
{
numerator = num;
}

-(void) set_denominator: (int) denom
{
denominator = denom;
}

//other
-(void) print
{
printf("The value of the fraction is %i/%i\n", numerator, denominator);
}

@end

//-------- program section -----------

int main(void)
{
Fraction* my_fract;
my_fract = [Fraction new];

[my_fract set_numerator: 1];
[my_fract set_denominator: 3];

printf("The numerator is %i, and teh denominator is %i\n", [my_fract numerator], [my_fract denominator]);
[my_fract print];

[my_fract free]; //frees the memory that was used by Fraction object

return 0;
}

3) I compiled it with:
gcc -framework Foundation prog18-2.m -o prog18-2

4) Terminal generated the following:
prog18-2.m: In function ‘main’:
prog18-2.m:58: warning: ‘Fraction’ may not respond to ‘+new’
prog18-2.m:58: warning: (Messages without a matching method signature
prog18-2.m:58: warning: will be assumed to return ‘id’ and accept
prog18-2.m:58: warning: ‘...’ as arguments.)
prog18-2.m:71: warning: ‘Fraction’ may not respond to ‘-free’

Thank you!
AnswerRe: Objective C first program from the book, warning messages Pin
BharathReddy V12-Jan-16 3:04
BharathReddy V12-Jan-16 3:04 
QuestionLinker command failed with exit code 1 (use -v to see invocation) in xcode 5.1.1 Pin
Member 1198376314-Sep-15 11:17
Member 1198376314-Sep-15 11:17 
QuestionImagePickerController image size Pin
liel333-Aug-15 12:30
liel333-Aug-15 12:30 
AnswerRe: ImagePickerController image size Pin
biji cabe18-Dec-16 23:25
biji cabe18-Dec-16 23:25 
QuestioniOS XMPP received message in coversation screen Pin
Member 1176696715-Jun-15 3:37
Member 1176696715-Jun-15 3:37 
SuggestionRe: iOS XMPP received message in coversation screen Pin
Richard MacCutchan15-Jun-15 5:19
mveRichard MacCutchan15-Jun-15 5:19 
GeneralRe: iOS XMPP received message in coversation screen Pin
Member 1176696715-Jun-15 21:42
Member 1176696715-Jun-15 21:42 
AnswerRe: iOS XMPP received message in coversation screen Pin
Dennis E White17-Jun-15 6:54
professionalDennis E White17-Jun-15 6:54 
Questionmake a system monitor using obj c. Pin
Member 116779679-May-15 14:00
Member 116779679-May-15 14:00 
AnswerRe: make a system monitor using obj c. Pin
Richard MacCutchan9-May-15 22:10
mveRichard MacCutchan9-May-15 22:10 
GeneralRe: make a system monitor using obj c. Pin
Dennis E White15-May-15 6:25
professionalDennis E White15-May-15 6:25 
GeneralRe: make a system monitor using obj c. Pin
Richard MacCutchan15-May-15 6:41
mveRichard MacCutchan15-May-15 6:41 
GeneralRe: make a system monitor using obj c. Pin
Dennis E White15-May-15 7:04
professionalDennis E White15-May-15 7:04 
GeneralApp that converts human years to dog years Pin
Member 115920608-Apr-15 16:44
Member 115920608-Apr-15 16:44 
GeneralRe: App that converts human years to dog years Pin
Dennis E White11-Apr-15 10:34
professionalDennis E White11-Apr-15 10:34 
GeneralRe: App that converts human years to dog years Pin
Richard MacCutchan11-Apr-15 23:05
mveRichard MacCutchan11-Apr-15 23:05 
GeneralRe: App that converts human years to dog years Pin
Dennis E White13-Apr-15 11:09
professionalDennis E White13-Apr-15 11:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.