use % operator in xcode

i'm trying to make a function that use % operator in objective c my function is:

-(void) image1:(UIImageView *)img1 
        image10:(UIImageView *)img10 
        image100:(UIImageView *)img100 
        score:(NSInteger *)sc
        NSInteger* s100,s10,s1;

    s100 = sc % 100;
    s10 = (sc - s100 * 100) % 10;
    s1 = (sc - sc % 10);

but i got errors.. can you guide me to some solution


You can't implicitly create objects like that. You want s100, s10, s1 and sc all to be C-style variables, but you've declared s100 and sc as pointers, as though they were going to hold Objective-C objects. I suggest you change NSInteger* to NSInteger in both cases. Not all things starting in NS are objects.

NSInteger is a primitive type. Depending on the environment it is either typedef'd to a 32 bit or 64 bit signed integer.

s100's declaration is

NSInteger* s100

so s100 is a pointer. Taking the modulus of a pointer is wrong. That line should be:

NSInteger s100,s10,s1;

And sc should probably be an NSInteger too. If you do really want to pass a pointer to an NSInteger, you need to dereference it when you do arithmetic with it:

s100 = *sc % 100;
s10 = (*sc - s100 * 100) % 10;
s1 = (*sc - *sc % 10);

Need Your Help

PL/SQL function while loop returning 1 row only

oracle plsql

I have tables(Customers,Pbasket and pp) with the following values inserted to the table

User preferences in Silverligth web application


I need to create a user preferences dialog in a Silverlight web application in a way that a user can change settings (let's say background color in main window) and see the results after clicking o...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.