Permalink
Browse files

FIXED › Compatibility with iOS4 (replaced deprecated methods)

  • Loading branch information...
1 parent bbb990f commit e17cf1e739bd87bcc25ca0070548e60e83b6203c @mdestagnol mdestagnol committed Mar 18, 2011
View
6 NKDAbstractUPCEANBarcode.m 100644 → 100755
@@ -2,7 +2,7 @@
// NKDAbstractUPCEANBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Sat May 11 2002.
-// ©2002 Naked Software. All rights reserved.
+// 2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
@@ -102,8 +102,8 @@ -(void)generateChecksum
int evenSum = 0;
int i, checkInt;
int even = 1;
- //char * code = (char *) [content lossyCString];
- char * code = (char *) [content cString];
+ //char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
+ char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(code) == 11)
{
i = strlen(code);
View
4 NKDBarcode.m 100644 → 100755
@@ -167,7 +167,7 @@ -(BOOL) isContentValid
int i;
char *contentString;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(contentString); i++)
if ([[self _encodeChar:contentString[i]] isEqual:@""])
@@ -202,7 +202,7 @@ -(NSString *)barcode
int i;
char *contentString;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(contentString); i++)
[theReturn appendString:[self _encodeChar:contentString[i]]];
View
@@ -43,7 +43,7 @@ -(void)generateChecksum
// -----------------------------------------------------------------------------------
{
int startCode=0, sum=0;
- char *code = (char *)[[self content] lossyCString];
+ char *code = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
switch (codeSet)
{
@@ -64,7 +64,7 @@ -(void)generateChecksum
sum += j * [self _valueForChar:code[i]];
else { // SET_C
if(codeLen % 2 != 0){
- code = (char *)[[NSString stringWithFormat:@"0%@", [self content]] lossyCString];
+ code = (char *)[[NSString stringWithFormat:@"0%@", [self content]] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
codeLen ++;
}
for (int i=0, j = 1; i < codeLen; i+=2, j++){
@@ -611,7 +611,7 @@ -(CodeSet)_bestCodeSetForContent
numNonPrinting = 0,
numLowerCase = 0,
i;
- char *code = (char *)[[self content] lossyCString];
+ char *code = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i=0; i < strlen(code); i++)
{
@@ -862,14 +862,14 @@ -(NSString *)barcode
// -----------------------------------------------------------------------------------
{
NSMutableString *theReturn = [NSMutableString stringWithString:@""];
- char * code = (char *)[[self content] lossyCString];
+ char * code = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
int i;
if (codeSet == SET_C)
{
// Left-pad with zero if odd number of characters
if (strlen(code)%2 != 0)
- code = (char *)[[NSString stringWithFormat:@"0%@",[NSString stringWithCString:code]] lossyCString];
+ code = (char *)[[NSString stringWithFormat:@"0%@",[NSString stringWithCString:code encoding:NSStringEncodingConversionAllowLossy]] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
// Encode character pairs
for (i=0; i < strlen(code); i+=2)
View
4 NKDCode39Barcode.m 100644 → 100755
@@ -135,7 +135,7 @@ -(BOOL) isContentValid
// -----------------------------------------------------------------------------------
{
int i;
- char *contentString = (char *)[[self content] lossyCString];
+ char *contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(contentString); i++)
{
@@ -150,7 +150,7 @@ -(void)generateChecksum
{
int theSum=0;
int i, checkValue;
- char *contentString = (char *)[[self content] lossyCString];
+ char *contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(contentString); i++)
{
View
14 NKDEAN13Barcode.m 100644 → 100755
@@ -28,7 +28,7 @@ -(id)initWithContent: (NSString *)inContent
if ([[self content] length] >= 13)
{
- tempString = (char *)[[self content] lossyCString];
+ tempString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
checkDigit = tempString[12];
[self setContent:[[self content] substringWithRange:range]];
//[self generateChecksum];
@@ -47,7 +47,7 @@ -(NSString *)barcode
int i;
char *contentString;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
// First six characters after system digit encoded with left-hand encoding,
@@ -210,7 +210,7 @@ -(void)generateChecksum
int oddSum = 0;
int evenSum = 0;
int i, checkInt;
- char * code = (char *) [content lossyCString];
+ char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(code) == 11)
{
@@ -233,7 +233,7 @@ -(void)generateChecksum
int oddSum = 0;
int evenSum = 0;
int i, checkInt;
- char * code = (char *) [content lossyCString];
+ char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(code) == 12)
{
@@ -259,8 +259,8 @@ -(void)generateChecksum
int evenSum = 0;
int i, checkInt;
int even = 1;
- //char * code = (char *) [content lossyCString];
- char * code = (char *) [content cString];
+ //char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
+ char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(code) == 12)
{
i = strlen(code);
@@ -286,7 +286,7 @@ -(BOOL) isContentValid
char *contentString;
char tempCheck=0;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(contentString) != 12)
return NO;
View
@@ -2,7 +2,7 @@
// NKDIndustrialTwoOfFiveBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Fri May 10 2002.
-// ©2002 Naked Software. All rights reserved.
+// 2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
@@ -23,7 +23,7 @@ -(NSString *)barcode
// Include the checkdigit if appropriate
NSMutableString *encodeTemp = (checkDigit == -1) ? [NSMutableString stringWithString:content]
: [NSMutableString stringWithFormat:@"%@%c", content, checkDigit];
- barcode = (char *)[encodeTemp lossyCString];
+ barcode = (char *)[encodeTemp cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(barcode); i++)
{
View
@@ -2,7 +2,7 @@
// NKDInterleavedTwoOfFiveBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Sat May 04 2002.
-// ©2002 Naked Software. All rights reserved.
+// 2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
@@ -27,7 +27,7 @@ -(NSString *)barcode
if ([encodeTemp length] %2 != 0)
[encodeTemp insertString:@"0" atIndex:0];
- barcode = (char *)[encodeTemp lossyCString];
+ barcode = (char *)[encodeTemp cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(barcode); i+=2)
{
@@ -106,7 +106,7 @@ -(void)generateChecksum
NSMutableString *tempContent = ([content length] %2 == 0) ? [NSMutableString stringWithString:content]
: [NSMutableString stringWithFormat:@"0%@", content];
- char *encodeString = (char *)[tempContent lossyCString];
+ char *encodeString = (char *)[tempContent cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(encodeString); i += 2)
{
@@ -123,7 +123,7 @@ -(BOOL) isContentValid
{
// Interleaved 2 of 5 can only encode numbers
int i;
- char *code = (char *)[content lossyCString];
+ char *code = (char *)[content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i=0; i < strlen(code);i++)
{
View
6 NKDModifiedPlesseyBarcode.m 100644 → 100755
@@ -2,7 +2,7 @@
// NKDModifiedPlesseyBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Tue May 07 2002.
-// ©2002 Naked Software. All rights reserved.
+// 2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
@@ -76,7 +76,7 @@ -(void)generateChecksum
// -----------------------------------------------------------------------------------
{
NSMutableString *newNum = [NSMutableString stringWithString:@""];
- char *code = (char *)[[self content] lossyCString], *productString;
+ char *code = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy], *productString;
NSNumber *product;
int i, productSum=0;
@@ -90,7 +90,7 @@ -(void)generateChecksum
product = [NSNumber numberWithInt:[newNum intValue] * 2];
// Add all of the digits of the product from step two.
- productString = (char *)[[product stringValue] lossyCString];
+ productString = (char *)[[product stringValue] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(productString); i++)
productSum += (productString[i] - '0');
View
6 NKDPostnetBarcode.m 100644 → 100755
@@ -2,7 +2,7 @@
// NKDPostnetBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Sun May 05 2002.
-// ©2002 Naked Software. All rights reserved.
+// 2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
@@ -96,7 +96,7 @@ -(float)_heightForDigit:(int)index
andBar:(int)bar
// -----------------------------------------------------------------------------------
{
- char * barcode = (char *) [content lossyCString];
+ char * barcode = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
char check;
check = (index >= strlen(barcode)) ? checkDigit : barcode[index];
@@ -201,7 +201,7 @@ -(float)_heightForDigit:(int)index
-(void)generateChecksum
// -----------------------------------------------------------------------------------
{
- char * code = (char *)[[self content] lossyCString];
+ char * code = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
int i, sum=0;
for (i = 0; i < strlen(code); i++)
View
10 NKDUPCABarcode.m 100644 → 100755
@@ -23,7 +23,7 @@ -(id)initWithContent: (NSString *)inContent
if ([content length] >= 12)
{
- tempString = (char *)[[self content] lossyCString];
+ tempString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
checkDigit = tempString[11];
[self setContent:[[self content] substringWithRange:range]];
//[self generateChecksum];
@@ -44,7 +44,7 @@ -(NSString *)barcode
int i;
char *contentString;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
// First six characters (number system character plus first
// five digits) encoded with left hand (odd) parity.
@@ -76,7 +76,7 @@ -(void)generateChecksum
int evenSum = 0;
int i, checkInt;
int even = 1;
- char * code = (char *) [content cString];
+ char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(code) == 11)
{
i = strlen(code);
@@ -100,7 +100,7 @@ -(void)generateChecksum
int oddSum = 0;
int evenSum = 0;
int i, checkInt;
- char * code = (char *) [content lossyCString];
+ char * code = (char *) [content cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(code) == 11)
{
@@ -139,7 +139,7 @@ -(BOOL) isContentValid
char *contentString;
char tempCheck;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
if (strlen(contentString) != 11)
return NO;
View
4 NKDUPCEBarcode.m 100644 → 100755
@@ -40,7 +40,7 @@ -(NSString *)barcode
char *contentString;
char numSystem;
- contentString = (char *)[[self content] lossyCString];
+ contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
numSystem = contentString[0];
// We skip over number system digit and encode the middle six, using the check digit
@@ -96,7 +96,7 @@ -(float)barBottom:(int)index
-(BOOL) isContentValid
// -----------------------------------------------------------------------------------
{
- char *contentString = (char *)[[self content] lossyCString];
+ char *contentString = (char *)[[self content] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
// Number System must be 0 or 1, elsewise it's an EAN-8 value and needs to be
// instantiated as an NKDEAN8Barcode
View
4 NSString-UPCEAN.m 100644 → 100755
@@ -18,7 +18,7 @@ -(NSString *)swapHandedness
{
int i;
NSMutableString *ret = [NSMutableString stringWithString:@""];
- char *code = (char *) [self lossyCString];
+ char *code = (char *) [self cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
for (i = 0; i < strlen(code); i++)
{
@@ -36,7 +36,7 @@ -(NSString *)swapParity
/*
To arrive at the even encoding, work from the left encoding and do the following: 1) Change all the 1's to 0's and 0's to 1. 2) Read the resulting encoding in reverse order (from right to left). The result is the "left-hand even" encoding pattern.
*/
- char *tmp = (char *)[[self swapHandedness] lossyCString];
+ char *tmp = (char *)[[self swapHandedness] cStringUsingEncoding:NSStringEncodingConversionAllowLossy];
NSMutableString *ret = [NSMutableString stringWithString:@""];
int i;

0 comments on commit e17cf1e

Please sign in to comment.