Hey Steve,

Just noticed your CDVShared.h commit. For iOS, we have to be really careful
about namespacing since Obj-C has no namespaces. The category name should
being with "CDV". So, instead of JSONMethods, it should be
"CDVJSONMethods", or maybe: "CDVExtensions".

Since categories are a bit of a murky area, it's also important that each
category on a class go in a file names after the class it's modifying.
These methods should go in:

NSError+CDVExtensions.h
CLLocation+CDVExtensions.h

Just did a grep, and don't actually see these new methods used anywhere...
There is a copy of them in CDVLocation.m, but that's it. Maybe we can just
delete them?


On Tue, Jun 25, 2013 at 8:01 PM, <ste...@apache.org> wrote:

> Updated Branches:
>   refs/heads/3.0.0 9ca742180 -> f705b31e2
>
>
> added cdvshared
>
>
> Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
> Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f705b31e
> Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f705b31e
> Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f705b31e
>
> Branch: refs/heads/3.0.0
> Commit: f705b31e27693bf44f7f2231cb438fa7809e7fba
> Parents: 9ca7421
> Author: Steven Gill <stevengil...@gmail.com>
> Authored: Tue Jun 25 17:01:09 2013 -0700
> Committer: Steven Gill <stevengil...@gmail.com>
> Committed: Tue Jun 25 17:01:09 2013 -0700
>
> ----------------------------------------------------------------------
>  CordovaLib/Classes/CDVShared.h                  | 35 ++++++++++++
>  CordovaLib/Classes/CDVShared.m                  | 59 ++++++++++++++++++++
>  CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 10 +++-
>  3 files changed, 103 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f705b31e/CordovaLib/Classes/CDVShared.h
> ----------------------------------------------------------------------
> diff --git a/CordovaLib/Classes/CDVShared.h
> b/CordovaLib/Classes/CDVShared.h
> new file mode 100644
> index 0000000..0b59a37
> --- /dev/null
> +++ b/CordovaLib/Classes/CDVShared.h
> @@ -0,0 +1,35 @@
> +/*
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements.  See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership.  The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License.  You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing,
> + software distributed under the License is distributed on an
> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + KIND, either express or implied.  See the License for the
> + specific language governing permissions and limitations
> + under the License.
> + */
> +
> +#import <Foundation/Foundation.h>
> +#import <CoreLocation/CoreLocation.h>
> +
> +
> +@interface NSError (JSONMethods)
> +
> +- (NSString*)JSONRepresentation;
> +
> +@end
> +
> +@interface CLLocation (JSONMethods)
> +
> +- (NSString*)JSONRepresentation;
> +
> +@end
> +
>
>
> http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f705b31e/CordovaLib/Classes/CDVShared.m
> ----------------------------------------------------------------------
> diff --git a/CordovaLib/Classes/CDVShared.m
> b/CordovaLib/Classes/CDVShared.m
> new file mode 100644
> index 0000000..8756c17
> --- /dev/null
> +++ b/CordovaLib/Classes/CDVShared.m
> @@ -0,0 +1,59 @@
> +/*
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements.  See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership.  The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License.  You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing,
> + software distributed under the License is distributed on an
> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + KIND, either express or implied.  See the License for the
> + specific language governing permissions and limitations
> + under the License.
> + */
> +
> +#import "CDVShared.h"
> +
> +#pragma mark -
> +#pragma mark CLLocation(JSONMethods)
> +
> +@implementation CLLocation (JSONMethods)
> +
> +- (NSString*)JSONRepresentation
> +{
> +    return [NSString stringWithFormat:
> +            @"{ timestamp: %.00f, \
> +            coords: { latitude: %f, longitude: %f, altitude: %.02f,
> heading: %.02f, speed: %.02f, accuracy: %.02f, altitudeAccuracy: %.02f } \
> +            }",
> +            [self.timestamp timeIntervalSince1970] * 1000.0,
> +            self.coordinate.latitude,
> +            self.coordinate.longitude,
> +            self.altitude,
> +            self.course,
> +            self.speed,
> +            self.horizontalAccuracy,
> +            self.verticalAccuracy
> +            ];
> +}
> +
> +@end
> +
> +#pragma mark NSError(JSONMethods)
> +
> +@implementation NSError (JSONMethods)
> +
> +- (NSString*)JSONRepresentation
> +{
> +    return [NSString stringWithFormat:
> +            @"{ code: %d, message: '%@'}",
> +            self.code,
> +            [self localizedDescription]
> +            ];
> +}
> +
> +@end
> \ No newline at end of file
>
>
> http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f705b31e/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
> ----------------------------------------------------------------------
> diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
> b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
> index bf92ac3..2d97260 100644
> --- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
> +++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
> @@ -7,6 +7,8 @@
>         objects = {
>
>  /* Begin PBXBuildFile section */
> +               1B701028177A61CF00AE11F4 /* CDVShared.h in Headers */ =
> {isa = PBXBuildFile; fileRef = 1B701026177A61CF00AE11F4 /* CDVShared.h */;
> };
> +               1B701029177A61CF00AE11F4 /* CDVShared.m in Sources */ =
> {isa = PBXBuildFile; fileRef = 1B701027177A61CF00AE11F4 /* CDVShared.m */;
> };
>                 1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers
> */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /*
> CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
>                 1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources
> */ = {isa = PBXBuildFile; fileRef = 1F92F49F1314023E0046367C /*
> CDVPluginResult.m */; };
>                 301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */ = {isa =
> PBXBuildFile; fileRef = 301F2F2914F3C9CA003FE9FC /* CDV.h */; settings =
> {ATTRIBUTES = (Public, ); }; };
> @@ -57,6 +59,8 @@
>  /* End PBXBuildFile section */
>
>  /* Begin PBXFileReference section */
> +               1B701026177A61CF00AE11F4 /* CDVShared.h */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
> name = CDVShared.h; path = Classes/CDVShared.h; sourceTree = "<group>"; };
> +               1B701027177A61CF00AE11F4 /* CDVShared.m */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc;
> name = CDVShared.m; path = Classes/CDVShared.m; sourceTree = "<group>"; };
>                 1F92F49E1314023E0046367C /* CDVPluginResult.h */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
> name = CDVPluginResult.h; path = Classes/CDVPluginResult.h; sourceTree =
> "<group>"; };
>                 1F92F49F1314023E0046367C /* CDVPluginResult.m */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc;
> name = CDVPluginResult.m; path = Classes/CDVPluginResult.m; sourceTree =
> "<group>"; };
>                 301F2F2914F3C9CA003FE9FC /* CDV.h */ = {isa =
> PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
> name = CDV.h; path = Classes/CDV.h; sourceTree = "<group>"; };
> @@ -207,12 +211,14 @@
>                                 30C684921407044A004C1A8E /*
> CDVURLProtocol.h */,
>                                 30C684931407044A004C1A8E /*
> CDVURLProtocol.m */,
>                                 30C6847E1406CB38004C1A8E /* CDVWhitelist.h
> */,
> +                               1B701026177A61CF00AE11F4 /* CDVShared.h */,
> +                               1B701027177A61CF00AE11F4 /* CDVShared.m */,
>                                 30C6847F1406CB38004C1A8E /* CDVWhitelist.m
> */,
>                                 30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
>                                 30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
>                                 1F92F49E1314023E0046367C /*
> CDVPluginResult.h */,
>                                 1F92F49F1314023E0046367C /*
> CDVPluginResult.m */,
> -                EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
> +                               EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
>                                 EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
>                                 8887FD341090FBE7009987E8 /*
> CDVInvokedUrlCommand.h */,
>                                 8887FD351090FBE7009987E8 /*
> CDVInvokedUrlCommand.m */,
> @@ -290,6 +296,7 @@
>                                 EBFF4DBD16D3FE2E008F452B /*
> CDVWebViewDelegate.h in Headers */,
>                                 EB96673B16A8970A00D86CDF /*
> CDVUserAgentUtil.h in Headers */,
>                                 7E14B5A81705050A0032169E /* CDVTimer.h in
> Headers */,
> +                               1B701028177A61CF00AE11F4 /* CDVShared.h in
> Headers */,
>                         );
>                         runOnlyForDeploymentPostprocessing = 0;
>                 };
> @@ -368,6 +375,7 @@
>                                 EB96673C16A8970A00D86CDF /*
> CDVUserAgentUtil.m in Sources */,
>                                 EBFF4DBC16D3FE2E008F452B /*
> CDVWebViewDelegate.m in Sources */,
>                                 7E14B5A91705050A0032169E /* CDVTimer.m in
> Sources */,
> +                               1B701029177A61CF00AE11F4 /* CDVShared.m in
> Sources */,
>                         );
>                         runOnlyForDeploymentPostprocessing = 0;
>                 };
>
>

Reply via email to